当前位置: 动力学知识库 > 问答 > 编程问答 >

android - Lollipop Writing and reading to an from the sd card

问题描述:

I'm making an application for a friend of mine's Sony Xperia D5803 phone. In the application I create data and write it to the SD card. When a user opens the app again, the phone reads it in and does so correctly. I have both permissions for writing and reading to the sd card.

The problem is that while my app reads the stored data from the SD card correctly, I personally can't see the folders and files my app created on the SD card when I open it via Micro USB on Ubuntu. I've tried checking the show hidden files options, but my app's files still do not show in the file manager.

What is also strange is that when I open the app's info in the settings OS says that there is no app data on the SD card, but there is some in the phone itself, which is strange, because I'm using this code to write and read from the SD card:

File sdCard = Environment.getExternalStorageDirectory();

File cookiesDirectory = new File(sdCard.getAbsolutePath()+"/settings/");

cookiesDirectory.mkdirs();

File outputSettings = new File(cookiesDirectory, "settings.txt");

FileOutputStream writersettings = null;

try {

writersettings = new FileOutputStream(outputSettings);

writersettings.write(settingsarray.toString().getBytes());

}

finally {

writersettings.close();

}

分享给朋友:
您可能感兴趣的文章:
随机阅读: