我正在尝试获取列 threadid 的值,其中 id(它是唯一的)等于我发送到 getthreadid 函数的 id。threadid 包含 long 数据类型的值,但我不知道为什么我的应用程序崩溃了这样做,请帮助,在此先感谢。
long id;
long threadid = datasource.getthreadid(id);
Toast.makeText(getActivity(), String.valueOf(threadid), Toast.LENGTH_SHORT).show();
public long getthreadid(long id)
{
String ide = String.valueOf(id);
String queryz = "SELECT " + "," + MySQLiteHelper.COLUMN_THREADID
+ " FROM " + MySQLiteHelper.TABLE_NAME
+ " WHERE " + MySQLiteHelper.COLUMN_ID + "=" + ide;
Cursor cursor = database.rawQuery(queryz, null);
long threadid = cursor.getLong(cursor.getColumnIndex("threadid"));
return threadid;
}
我的数据库创建查询是:
static final String DATABASE_CREATE = "create table "+"message"+
"( " +"id"+" integer primary key autoincrement,"+ "threadid long,parentid integer,message text not null,messagestatus text); ";