I have an app made witch has in /data/data/com.pakage.name/app_webview/Local Storage/file__0.localstorage data saved in a table. Is it a real .db file? How can I use that table in android and query for some files, like this:
String sql = "SELECT value FROM ItemTable WHERE key='fav_list'";
I tried this: f.getPath is the path to the file
File dbfile = getApplicationContext().getDatabasePath(f.getPath()); dbfile.setWritable(true); SQLiteDatabase db = SQLiteDatabase.openDatabase(dbfile.getAbsolutePath(), null, SQLiteDatabase.OPEN_READWRITE);
I can respond to my own answer after a little research.
Is it a real .db file?
yes it is a database.
here it's how I managed to acces the row from column i wanted:
Cursor cursor = null;
SQLiteDatabase db = null;
try {
File dbfile = getApplicationContext().getDatabasePath(f.getPath());
dbfile.setWritable(true);
db = SQLiteDatabase.openDatabase(dbfile.getAbsolutePath(), null, SQLiteDatabase.OPEN_READWRITE);
String sql = "SELECT value FROM ItemTable WHERE key='fav_list'";
cursor = db.rawQuery(sql, null);
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
byte[] itemByteArray = cursor.getBlob(0);
String itemString = new String(itemByteArray, Charset.forName("UTF-16LE"));
cursor.moveToNext();
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (cursor != null) {
cursor.close();
}
if (db != null) {
db.close();
}
}
and with itemString you can do what you want. :)
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.