简体   繁体   中英

database folder is missing in device file explorer in android studio

I have created a sqlite database and table in android studio, but the sqlite database folder is missing in the device's file explorer. I have written the following code in the databasehelper.java class

@Override
public void onCreate(SQLiteDatabase db) {
   db.execSQL("create table "+TABLE_NAME+"(sr INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, datetime TEXT, location TEXT, odometer INTEGER, speed INTEGER, GPS TEXT, int.volt INTEGER, ext.volt INTEGER )");
}   

There might be a possibility that you have not connected the android device in USB file transfer mode. I had this issue in Android 9 and fixed it by connecting the device in USB file transfer mode.

The default location of database is

/data/data/<your_app_packagename>/databases/db_name. 

It is not accessible in non-rooted devices. You can create your database in different location for debugging.

solved this issue. now my database folder is visible in device file explorer. i delete my old database. also remove databaseHelper class. and create a fresh database and table. may be i missed some steps while creating database thats why database folder is missing. now its working.. thank you for ur help

Firstly you need to check that your database is successfully created or not, if your database is created then you can follow these steps:

  • Step1 : Debug you device with the breakpoint on the createdatabase().
  • Step2 : After the successfully database create, Open the Device File Explorer, Go to the your Package and right click onto the package name.
  • Step3: Synchronize you package, now you will get your Database

1 create table 2 upgrade table 3 insert value in table 4 (make sure that) add table field in List and call the method in MainActivity eg. - db.gelAlldata(); 5 then run and synchronize ur project package

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