Android permission of creating database

前端 未结 6 1878
悲&欢浪女
悲&欢浪女 2020-12-18 21:55

Hi I have some problems in creating the sqlite database in android.

Everything is ok on the emulator, I can create the database. But it doesn\'t work on the actually

相关标签:
6条回答
  • 2020-12-18 22:41

    It's very easy to solve You must have not added .db extension in your DataBase Name declared in the db java file For eg, public static final String DB_NAME = "tasks.db";

    DON'T FORGET THE .db EXTENSION

    0 讨论(0)
  • 2020-12-18 22:49

    at the first I check permissions and runtime get permission, but since the targetSdkVersion was 25, the problem was unsolved, work with db without use EXTENSION of .db always be good and worked, but its looks that targetSdkVersion of 25 need the EXTENSION of .db and my problem solved.

    0 讨论(0)
  • 2020-12-18 22:52

    Without any feedback in the error, it is impossible to tell you what's wrong in your code. Nevertheless, I can tell you that you do not need ACCESS_CHECKIN_PROPERTIES for using your own database. You should not need WRITE_EXTERNAL_STORAGE either unless you are trying to access the sdcard.

    The databases are stored by default in a subfolder of your app folder in the internal storage, i.e.:

    /data/data/YOUR_APP/databases/YOUR_DATABASAE.db
    

    If you do that on a physical device it has to be rooted though.

    0 讨论(0)
  • 2020-12-18 22:55

    I have cleared the app data from applications from settings, then uninstall and run the app with renaming the db file with .db extension, it works for me

    0 讨论(0)
  • 2020-12-18 22:56

    I had exactly the same problem. My application would create a db on the emulator, read and write data, but it crashed when on the device.

    I found a very simple solution to this: delete the database on your device manually at /data/data/YOUR_APP/databases/YOUR_DATABASAE.db and then rerun your app.

    Worked in my case, hope it helps.

    0 讨论(0)
  • 2020-12-18 22:56

    Maybe you have this problem because you have a prevoius version of your app installed on your phone. Before you install the new version try to uninstall the previous by "Application Manager". I solve in this way.

    0 讨论(0)
提交回复
热议问题