1

我想在 TextView 中显示数据库中某些列的值。我写了以下代码。但它没有在 LoadEmployee 方法中的 Log.e("problem","here") 之后运行。请帮忙

代码

public Cursor getTestData(String d) 

     { 

         try 
         {   
             String sql ="SELECT name FROM master WHERE sc =' "+ d +" '"; 


             Cursor mCur = mDb.rawQuery(sql, null); 

             mCur.moveToFirst();

             if (mCur!=null) 
             {  
                mCur.moveToNext(); 
             } 

             return mCur; 


         } 

         catch (SQLException mSQLException)  
         { 
             Log.e(TAG, "getTestData >>"+ mSQLException.toString()); 
             throw mSQLException; 
         }



public void LoadEmployee(View v)

    {


         TestAdapter mDbHelper = new TestAdapter(this);         
        mDbHelper.createDatabase();       
        mDbHelper.open(); 
        String d = info_sc.getText().toString();

        Cursor testdata = mDbHelper.getTestData(d); 

         testdata.moveToNext();

         Log.e("problem", "here");
        String title = testdata.getString(testdata.getColumnIndex("name"));

        info_bk.setText(title);

        mDbHelper.close();
    }

谢谢。

4

0 回答 0