在下面给定的程序中,我在表中插入了imei_number。但是我必须检索插入的数据并以不同的方法显示它。请提前指导。谢谢
onCreate() {
try {
imeiDB = this.openOrCreateDatabase(IMEI_DB_NAME, MODE_PRIVATE, null);
imeiDB.execSQL("CREATE TABLE IF NOT EXISTS " +
IMEI_TABLE_NAME +" (IMEI_number_db VARCHAR);");
imeiDB.execSQL("INSERT INTO " + IMEI_TABLE_NAME +" Values ("+IMEI_number_db+");");
Cursor c = imeiDB.rawQuery("SELECT IMEI_number_db FROM " + IMEI_TABLE_NAME , null);
if (c != null ) {
if (c.moveToFirst()) {
do {
IMEI_number = c.getString(c.getColumnIndex("IMEI_number_db"));
}while (c.moveToNext());
}
}
} catch (SQLiteException se ) {
Log.e(getClass().getSimpleName(), "Could not create or Open the database");
} finally {
if (imeiDB != null)
imeiDB.execSQL("DELETE FROM " + IMEI_TABLE_NAME);
imeiDB.close();
}
}
/ * ** * ** * ** * ** * *** /
fetch the data in another method
private collectdata()
{
String IMEI_number ="";
Cursor c = imeiDB.rawQuery("SELECT IMEI_number_db FROM " + IMEI_TABLE_NAME , null);
if (c != null ) {
if (c.moveToFirst()) {
do {
IMEI_number = c.getString(c.getColumnIndexOrThrow("IMEI_number_db"));
}while (c.moveToNext());
}
}
}