逻辑错误..我在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());
任何建议都被接受。按下此代码所在的此按钮后,Button直接指向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)
请帮助。我试图分析它,我分析了尝试创建新的套接字连接...它将其重定向到Mainactivity?我很困惑。
答案 0 :(得分:2)
更好地处理功能。在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;
}
然后是您的主要活动
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity);
userDbHelper =new UserDbHelper(this);
DataProvider dataProvider=userDbHelper.getInformations();
text = dataProvider.getText();
}