[英]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.我在 android 工作室中创建了一个 sqlite 数据库和表,但设备的文件资源管理器中缺少 sqlite 数据库文件夹。 I have written the following code in the databasehelper.java
class我在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.可能您没有在 USB 文件传输模式下连接 android 设备。 I had this issue in Android 9 and fixed it by connecting the device in USB file transfer mode.我在 Android 9 中遇到了这个问题,并通过以 USB 文件传输模式连接设备来修复它。
The default location of database is数据库的默认位置是
/data/data/<your_app_packagename>/databases/db_name.
It is not accessible in non-rooted devices.在非 root 设备中无法访问它。 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.还删除 databaseHelper 类。 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:首先你需要检查你的数据库是否成功创建,如果你的数据库已经创建,那么你可以按照以下步骤操作:
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. 1 创建表 2 升级表 3 在表中插入值 4(确保)在 List 中添加表字段并调用 MainActivity 中的方法,例如。 - db.gelAlldata(); - db.gelAlldata(); 5 then run and synchronize ur project package 5 然后运行并同步你的项目 package
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.