首先,我在 Android 应用程序中创建一个名为“mydb”的数据库:
DBHelper dbHelper = new DBHelper(context, "mydb", null, 1);//DBHelper is my custom class
并将一些数据写入其表中:
SQLiteDatabase db = dbHelper.getReadableDatabase();
db.execSQL("insert into mytable(name, text) values ('allen','hello')");
在这里,一切都好。但是,我手动删除这个数据库,而不是通过编程,使用软件“R.E.explore”(当然在有根设备上)。
然后,在我的代码中,我读取了数据库的这个表。令人惊讶的是我仍然可以获得我存储的数据。
Cursor cursor = db.query("mytable", new String[]{"name","text"}, null, null, null, null, null);
Why?