1
我被困在昨天。研究並沒有多大幫助,因爲我剛剛交出了這個項目,而且我對Android沒有任何瞭解。如何從SQLite數據庫轉儲結果
myDB = null;
try {
File dir = new File(Environment.getExternalStorageDirectory().getAbsolutePath());
File file = new File(dir, "database.db");
myDB = SQLiteDatabase.openDatabase(file.toString(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS|SQLiteDatabase.OPEN_READONLY);
String q = "SELECT * FROM companies";
Cursor mCursor = myDB.rawQuery(q, null);
Context context = getActivity().getApplicationContext();
CharSequence text = mCursor.toString();
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
myDB.close();
} catch (SQLException e) {
e.printStackTrace();
}
從烤麪包,我得到[email protected]
如何轉儲所有數據庫結果?
哇,真棒這個作品謝謝! –