I have a problem to select from alist of data from database. The logcat prompt :
Caused by: android.database.sqlite.SQLiteException: no such table: hadis (code 1): , while compiling: SELECT hadis_id,no_hadis,tajuk_hadis,hadis,terjemahan,tajuk_audio_hadis,audio_hadis,pengajaran_hadis,sebab_wurud_hadis FROM hadis
Here is the method that I have called the database :
public ArrayList<HashMap<String, String>> getHadisList() {
//Open connection to read only
//SQLiteDatabase db = dbHelperHadis.getReadableDatabase();
String selectQuery = "SELECT " +
Hadis.KEY_hadisID + "," +
Hadis.KEY_noHadis + "," +
Hadis.KEY_tajukHadis + "," +
Hadis.KEY_hadis + "," +
Hadis.KEY_terjemahan + "," +
Hadis.KEY_tajukAudio + "," +
Hadis.KEY_audioHadis + "," +
Hadis.KEY_pengajaranHadis + "," +
Hadis.KEY_sebabWurud +
" FROM " + TABLE_LOCATION;
SQLiteDatabase db = SQLiteDatabase.openDatabase( DB_PATH + DB_NAME , null, SQLiteDatabase.OPEN_READWRITE);
//Student student = new Student();
ArrayList<HashMap<String, String>> hadisList = new ArrayList<HashMap<String, String>>();
Cursor cursor = db.rawQuery(selectQuery, null);
// looping through all rows and adding to list
if (cursor.moveToFirst()) {
do {
HashMap<String, String> hadis = new HashMap<String, String>();
hadis.put("id", cursor.getString(cursor.getColumnIndex(Hadis.KEY_hadisID)));
hadis.put("name", cursor.getString(cursor.getColumnIndex(Hadis.KEY_noHadis)));
hadisList.add(hadis);
} while (cursor.moveToNext());
}
cursor.close();
db.close();
return hadisList;
}
Can anyone help me? Thanks
Aucun commentaire:
Enregistrer un commentaire