Skip to content Skip to sidebar Skip to footer

Android - Can Not Find The File Although It Exists In The Data Folder?

I am trying to copy the SQLite database from the data folder to SDCard using Emulator, i am using below code, which i found here. try { File sd = Environment.getExternalStorage

Solution 1:

Well guys i just removed the ".db" extension & it works now! See the updated code below:

try 
 {
    Filesd= Environment.getExternalStorageDirectory();
    Filedata= Environment.getDataDirectory();

    if (sd.canWrite()) {
        StringcurrentDBPath="\\data\\PackageName\\databases\\myDB";
        StringbackupDBPath="myDB";
        FilecurrentDB=newFile(data, currentDBPath);
        FilebackupDB=newFile(sd, backupDBPath);

        if (currentDB.exists()) 
        {
           // code to copy from currentDB  to backupDB 
        }
    }
} catch (Exception e) {
}

myDB.db is replaced with "myDB".

Post a Comment for "Android - Can Not Find The File Although It Exists In The Data Folder?"