I posted this on stackoverflow, but I thought maybe I'd have more luck 
here...

I have a strange problem where my SQL database doesn't remove itself when I 
uninstall the app

I'm not creating the database in any external storage directories, and the 
database is confirmed to be in its default location: 
/data/data/com.example.app/databases/

After I uninstall the app, I expect all the data in that location to be 
wiped, but when I run the app again from android studio the new install can 
still see all of the old data

I have tried using adb to manually delete the .db file from the databases 
directory, but when I run the app again the old data can still be seen

I have also tried going into the app settings and clearing the data and 
cache, but that doesn't seem to help

The only places in my code where I'm doing anything "strange" with regards 
to the database is I'm copying the database file to a new location on 
button click:

    String pathToExternalStorage = Environment.getExternalStorageDirectory
().toString();
    File exportDir = new File(pathToExternalStorage, "/SensorData");
    File subjectDataDir = new File(exportDir, "/subjects");
    
    File data = Environment.getDataDirectory();
    String currentDBPath = "//data//com.example.app//databases//" + DBHelper
.DATABASE_NAME;
    File currentDB = new File(data, currentDBPath);
    File destDB = new File(exportDir, DBHelper.DATABASE_NAME);
    
    FileChannel src = new FileInputStream(currentDB).getChannel();
    FileChannel dst = new FileOutputStream(destDB).getChannel();
    dst.transferFrom(src, 0, src.size());
    src.close();
    dst.close();


And then running mediascanner on the newly created file so I can get 
instant MTP access to it

I doubt that either of these processes could cause this to happen though?

My immediate question is how do I manually remove the database from the 
phone without root access?

The bigger question is what could be causing the uninstall process to not 
remove the database files? And how does a newly installed version of the 
app (after an uninstall) still see the old database information?

I'm not sure how to begin figuring this out...

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/690f04d7-ae01-448c-b26b-eaae0295e8b4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to