gpt4 book ai didi

java - 如何使用另一列仅获取一列数据

转载 作者:行者123 更新时间:2023-12-02 03:05:06 26 4
gpt4 key购买 nike

逻辑错误..我是 Android java 数据库的新手..没有错误,但我想你们明白我的意思。

getSearch = searchbar.getText() .toString();
searchquery = "SELECT * FROM words WHERE tagalog LIKE '%"+ getSearch +"%';";
sqLiteDatabase.rawQuery(searchquery,null);
Cursor c = wordsDBHelper.getdata(sqLiteDatabase);
searchRes.setText( c.getString(2).toString());

任何建议都会被接受。按下此代码所在的按钮后,按钮将直接指向 mainActivity。

heres the logcat
01-26 13:28:49.285 32177-32177/? D/dalvikvm: Late-enabling CheckJNI
01-26 13:28:49.305 32177-32177/com.example.leoandroid.translate W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/view/SearchEvent;)
01-26 13:28:49.305 32177-32177/com.example.leoandroid.translate I/dalvikvm: Could not find method android.view.Window$Callback.onSearchRequested, referenced from method android.support.v7.view.WindowCallbackWrapper.onSearchRequested
01-26 13:28:49.305 32177-32177/com.example.leoandroid.translate W/dalvikvm: VFY: unable to resolve interface method 17980: Landroid/view/Window$Callback;.onSearchRequested (Landroid/view/SearchEvent;)Z
01-26 13:28:49.305 32177-32177/com.example.leoandroid.translate D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
01-26 13:28:49.305 32177-32177/com.example.leoandroid.translate I/dalvikvm: Could not find method android.view.Window$Callback.onWindowStartingActionMode, referenced from method android.support.v7.view.WindowCallbackWrapper.onWindowStartingActionMode
01-26 13:28:49.305 32177-32177/com.example.leoandroid.translate W/dalvikvm: VFY: unable to resolve interface method 17984: Landroid/view/Window$Callback;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
01-26 13:28:49.305 32177-32177/com.example.leoandroid.translate D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
01-26 13:28:49.315 32177-32177/com.example.leoandroid.translate D/dalvikvm: GC_FOR_ALLOC freed 125K, 27% free 2723K/3728K, paused 10ms, total 10ms
01-26 13:28:49.315 32177-32177/com.example.leoandroid.translate I/dalvikvm-heap: Grow heap (frag case) to 7.125MB for 4651212-byte allocation
01-26 13:28:49.325 32177-32183/com.example.leoandroid.translate D/dalvikvm: GC_FOR_ALLOC freed <1K, 13% free 7265K/8272K, paused 10ms, total 10ms
01-26 13:28:49.355 32177-32177/com.example.leoandroid.translate I/dalvikvm: Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.widget.TintTypedArray.getChangingConfigurations
01-26 13:28:49.355 32177-32177/com.example.leoandroid.translate W/dalvikvm: VFY: unable to resolve virtual method 433: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
01-26 13:28:49.355 32177-32177/com.example.leoandroid.translate D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
01-26 13:28:49.355 32177-32177/com.example.leoandroid.translate I/dalvikvm: Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.widget.TintTypedArray.getType
01-26 13:28:49.355 32177-32177/com.example.leoandroid.translate W/dalvikvm: VFY: unable to resolve virtual method 455: Landroid/content/res/TypedArray;.getType (I)I
01-26 13:28:49.355 32177-32177/com.example.leoandroid.translate D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
01-26 13:28:49.435 32177-32177/com.example.leoandroid.translate I/PGA: Attempting to create new SOCKET connectionn pid = 32177, tid = 32177
01-26 13:28:49.445 32177-32177/com.example.leoandroid.translate I/PGA: New SOCKET connection: com.example.leoandroid.translate (pid 32177, tid 32177)

请帮忙。我尝试分析它并分析了尝试创建新的套接字连接...将其重定向到主要 Activity ?我很困惑。

最佳答案

更好地利用功能。在 DbHelper 类中创建函数,例如

     public DataProvider getInformations()
{
SQLiteDatabase db = this.getReadableDatabase();
Cursor res = db.rawQuery( "select "+your column+" from "+TABLE_NAME, null );
res.moveToFirst();
DataProvider dataProvider = new DataProvider();
while(res.isAfterLast() == false)
{
dataProvider.setText(res.getString(res.getColumnIndex(Columnname)));
res.moveToNext();
}
db.close();
return dataProvider;
}

然后是您的主要 Activity

    protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity);

userDbHelper =new UserDbHelper(this);
DataProvider dataProvider=userDbHelper.getInformations();
text = dataProvider.getText();

}

关于java - 如何使用另一列仅获取一列数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41858053/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com