简体   繁体   中英

Android Sqlite db creation / location issue

I am working with a basic example of Android Sqlite.

Issue 1:
As per this video , it runs perfectly without any errors but - when I take Android Device Monitor I cannot locate my project with full name -- all the folders under data > data are named as abc (which is the package extension only! )

在此处输入图片说明

As per the video , why is my ADM not showing the full package name such as abc.mycom.com.sqliteapp or how can I locate my db (students.db)?

Issue 2:
In order to solve this, when I try a specific path using

public  static final String DATABASE_NAME= "/mnt/sdcard/student.db";

I get ' Unfortunately the app has stopped ' error.

I have added the following permission: <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Please be careful about android permissions.In android 6.0 and above , there are some specific permissions that cannot be granted only by using manifest permission.WRITE_EXTERNAL_STORAGE won't work on android 6.0 and above if the user doesn't active it by going to "Application Info" -> "Permissions".And for get the app location "to store your data base" you don't need write external storage permission.Here is my code for get app data path:

    public static String getDataDir(Context context) throws Exception {
        return context.getPackageManager()
                .getPackageInfo(context.getPackageName(), 0)
                .applicationInfo.dataDir;
          }

However , please explain about your debugging error (LogCat).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM