Android 从长字符串转换为字符串[]
我得到了这个错误:Android 从长字符串转换为字符串[],android,sqlite,type-conversion,Android,Sqlite,Type Conversion,我得到了这个错误: The method query(String, String[], String, String[], String, String, String) in the type SQLiteDatabase is not applicable for the arguments (String, String[], String, String, null, null, null) 以及负责的代码: public Cursor getDomanda(String id) {
The method query(String, String[], String, String[], String, String, String) in the type SQLiteDatabase is not applicable for the arguments (String, String[], String, String, null, null, null)
以及负责的代码:
public Cursor getDomanda(String id) {
List<categorie> categorie = new ArrayList<categorie>();
Cursor cursor = database.query(MySQLiteHelper.TABLE_SONDAGGI,
allCategorieColumns, MySQLiteHelper.COLUMN_ID + "=", id, null, null, null);
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
categorie categoria = cursorToCategorie(cursor);
categorie.add(categoria);
cursor.moveToNext();
}
// Make sure to close the cursor
// cursor.close();
return cursor;
}
long strcategory = getIntent().getExtras().getLong("categoriaId");
Cursor values = datasource.getDomanda(Long.toString(strcategory));
我做错了什么?
我需要将长字符串转换为字符串[]
,但是字符串[]
到底是什么
顺便问一下,这个问题对吗?
我是说
是
select from tableSondaggi where _id = $id ?
第四个参数必须是
字符串[]
,而不是字符串
您需要将id
替换为newstring[]{id}
以创建由单个元素(您的id)组成的数组
第四个参数必须是
字符串[]
,而不是字符串
您需要将id
替换为newstring[]{id}
以创建由单个元素(您的id)组成的数组
这应该能奏效
Cursor cursor = database.query(MySQLiteHelper.TABLE_SONDAGGI,
allCategorieColumns, MySQLiteHelper.COLUMN_ID + "=", new String[] { id }, null, null, null);
但是:也许有必要读一些关于基本编程的书。数组(
String[]
例如)非常有用…这应该可以做到
Cursor cursor = database.query(MySQLiteHelper.TABLE_SONDAGGI,
allCategorieColumns, MySQLiteHelper.COLUMN_ID + "=", new String[] { id }, null, null, null);
但是:也许有必要读一些关于基本编程的书。数组(
String[]
例如)非常有用…你是在问数组是什么吗?什么是字符串[]
?对不起,我知道数组:D我只是有点累了:D:你敢问数组是什么吗?什么是字符串[]
?对不起,我知道数组:D我只是有点累了:D:D
Cursor cursor = database.query(MySQLiteHelper.TABLE_SONDAGGI,
allCategorieColumns, MySQLiteHelper.COLUMN_ID + "=", new String[] { id }, null, null, null);