Question

I changed the default directory of my database to the sdcard and I want to acccess this database and see its data using sqlitebrowser ,However I can see this database from my android file manager but when I am using windows file manager I cannot see the file of database in my sdcard , I thing it is about permission issues , But How can I solve that ?

my database is here

public static String SDCard =  Environment.getExternalStorageDirectory().getAbsolutePath()
    + File.separator ;
    public DatabaseHelper(Context context) {


        super(context, SDCard +DATABASE_NAME, null, DATABASE_VERSION);
        transactionManager = new TransactionManager(getConnectionSource());
    }
Was it helpful?

Solution

Some Android phones have their internal memory split into two blocks.

One is used for the internal or / folder. The other part of the internal memory is returned by getExternalStorageDirectory(). This is still internal memory from user and/or PC side. But for Android it is external memory.

So probably you are looking in the wrong folder.

For example in my Samsung S4 I have:

  /
  /storage/emulated/0
  /storage/extSdCard

"/storage/emulated/0" is returned from getExternalStorageDirectory(), while "/storage/extSdCard" is my external SD card.

OTHER TIPS

Physical Device

You need to have a phone with root access in order to browse the data folder (data/data/your.app.package.name) on an Android phone which means either you have a developer device or you've rooted your device.

(You also need to be running ADB in root mode and this can be achieved on the commandline using adb root)

If your phone does not have root access, you will not be able to gain access to the database.

The database will have rw-rw---- as the permission as default. In order to access the database you should change the permission level using chmod on *nix systems or through the folder permission dialogs in Windows (right click the folder and set permissions to everyone)

Emulated Device

See this previous answer. You can access the database using the DDMS perspective

Mounting a device in MTP mode has a bug where the MTP database isn't updated correctly and newly created objects are not visible to the client computer.

As a workaround, you can use MediaScannerConnection scanFile() to force refresh the database after creating your directories/files.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top