Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- E/UncaughtException: android.database.sqlite.SQLiteReadOnlyDatabaseException: attempt to write a readonly database (code 1032)
- #################################################################
- Error Code : 1032 (SQLITE_READONLY_DBMOVED)
- Caused By : Database or Journal file have been removed.
- (attempt to write a readonly database (code 1032))
- #################################################################
- at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native Method)
- public void moveContents(){
- File destinationFolder = new File(DATABASE_FOLDER_PATH);
- File sourceFolder = new File(Environment.getExternalStorageDirectory() + "/AppName/Backups/_extracts");
- if (!destinationFolder.exists())
- {
- destinationFolder.mkdirs();
- }
- // Check weather source exists and it is folder.
- if (sourceFolder.exists() && sourceFolder.isDirectory())
- {
- // Get list of the files and iterate over them
- File[] listOfFiles = sourceFolder.listFiles();
- if (listOfFiles != null)
- {
- for (File child : listOfFiles )
- {
- try {
- File checkFile=new File(destinationFolder+"/"+child.getName());
- if(checkFile.exists()){
- checkFile.delete();
- FileUtils.moveFileToDirectory(child,destinationFolder,false);
- }else{
- FileUtils.moveFileToDirectory(child,destinationFolder,false);
- }
- } catch (IOException e) {
- Log.e("FLERROR","ERROR",e);
- }
- // Move files to destination folder
- }
- // Add if you want to delete the source folder
- sourceFolder.delete();
- }
- }
- else
- {
- System.out.println(sourceFolder + " Folder does not exists");
- }
- }
Add Comment
Please, Sign In to add comment