如何从sqlite数据库android获取一个值?

时间:2018-02-03 18:49:53

标签: java android database sqlite

尝试运行此代码:

AppsDbHelper dbHelper = new AppsDbHelper(mContext);
            SQLiteDatabase database = dbHelper.getReadableDatabase();

            String query = "select launch from apps where name=com.google.android.apps.maps";
            Cursor cursor = database.rawQuery( query, null );

但面对这样的例外:

android.database.sqlite.SQLiteException: near ".": syntax error (code 1): , while compiling: select launch from apps where name=com.google.android.apps.maps

问题是什么以及如何解决?

提前感谢您的每一个答案!

1 个答案:

答案 0 :(得分:1)

为什么不尝试在单引号中包装com.google.android.apps.maps-> “

String query = "select launch from apps where name='com.google.android.apps.maps'";