我有问题从数据库中的数据中选择。我使用SQLite Browser创建了我的表,然后将数据库导入了工作室。我想从数据库中读取数据。这是数据库的初始化:
public static String DB_PATH = "data/data/com.psm.app.hadis40_07/databases/";
public static String DB_NAME = "hadis40_db";
public static String TABLE_LOCATION = "hadis";
logcat提示符:
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
这是我称之为数据库的方法:
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;
}
任何人都可以帮助我吗?感谢