1

android Unable to access files in SD card ####Android无法访问SD卡中的文件</p>

I am working on application where it create text files in the SD card.

I have a receiver which will execute logic to create files in SD card from that point I will keep on store some data into that .

So far it is working properly , but suddenly I stopped working.

I checked logcat output , I found some logs related to SD card mounting.

But do not have an idea to how to resolve this issue.

below are the log statements:

     1.464 W/Vold    ( 2357): Failed to unmount /mnt/secure/staging (Device or resource busy, retries 3, action 0)
     08-23 07:26:31.783 E/ProcessKiller( 2357): Process logcat (3344) has open file /mnt/secure/staging/abc1.txt
     08-23 07:26:31.783 E/ProcessKiller( 2357): Process logcat (3345) has open file /mnt/secure/staging/abc2.txt
     08-23 07:26:32.845 W/Vold    ( 2357): Failed to unmount /mnt/secure/staging (Device or resource busy, retries 2, action 1)
     08-23 07:26:33.173 E/ProcessKiller( 2357): Process logcat (3344) has open file /mnt/secure/staging/abc1.txt

I have added permission android.permission.WRITE_EXTERNAL_STORAGE

4

2 に答える 2

1

複数のスレッドを使用してファイルにアクセスしているからだと思います。したがって、ファイルを開く関数で同期を使用してみてください。

synchronized void openFile(String filePath) {
        // Code to open file
}
于 2012-11-21T05:34:59.080 に答える
0

テキストファイルをSDカードに書き込む前に、常にメディアの状態を確認する必要があります

if(Environment.getExternalStorageState().equalsIgnoreCase(Environment.MEDIA_MOUNTED))
{
    // read or write file logic here //
}
于 2012-11-21T03:47:35.917 に答える