我需要获取SQLite
数据库的路径才能打开它以查询语法:
rDb = SQLiteDatabase.openDatabase(mPath, null, 0);
其中mPath
将是数据库的路径,rDb
是数据库文件。
代码适用于此查询语句:
public ArrayList<String> getList(){ //List Query
String FOOD_TYPE = "";
String LOCATION = "";
String TAKEREST = "";
ArrayList<String> NameList = new ArrayList<String>();
String[] columns = new String[]{COLUMN_ROWID, COLUMN_NAME, COLUMN_TELEPHONE, COLUMN_EMAIL, COLUMN_MENUURL, COLUMN_WEBSITE, COLUMN_MOBILE, COLUMN_CUISINE, COLUMN_LOCATION, COLUMN_TAKEREST};
rDb = SQLiteDatabase.openDatabase(mPath, null, 0);
Cursor list = rDb.query(DATABASE_TABLE, columns,"food_type = ? AND location = ? AND Restaurant_or_takeaway = ?", new String[] {FOOD_TYPE, LOCATION, TAKEREST}, null, null, null);
for(list.moveToFirst(); !list.isAfterLast(); list.moveToNext()) {
Log.d("in loop", "msg");
NameList.add(list.getString(list.getColumnIndex(COLUMN_NAME)));
}
rDb.close();
return NameList;
}
关于如何解决这个问题的任何想法?
答案 0 :(得分:0)
您可以使用[databaseList]( http://developer.android.com/reference/android/content/Context.html)