开发者

get data from sqlite into edittext based on condition provided

I am working on an Android project where I am struck with a issue. I need to fetch data from SQLite db based on condition provided.

In precise I mean to say I need to get the data from SQLite where I provide condition an display that returned value i开发者_StackOverflow社区n EditText.

Like:

SELECT SPECIALCHARCTER FROM <TABLENAME> WHERE POSITION = "0"; 

I need a good link to study this process. Can anyone please help me in issue.

You can check out sample code of DBHelper.java class.

I shall be very happy to see reply from u friends and help me in solving this issue.

Thanks & Regards,

Raghav


Try select statement in the following way

SELECT * FROM  Contact where position LIKE '%"+0+"%'"

this may helps you


Sorry but you code pasted is a mess as it is not good formatted and filled with code that is commented out. Hard to see anything.

What I saw was this code:

EditText result=(EditText)findViewById(R.id.input);
Cursor c = db.rawQuery("SELECT SPECIALCHARCTER FROM " + TABLE + " where POSITION = 0", null);
int A = c.getColumnIndex("POSITION");
String strRet;
strRet = c.getString(A);
results.setText("" + strRet);
c.moveToNext();

This will fail for multiple reasons:

  1. Your cursor c is never moved to the first place before you access it. So it will always fail
  2. Calling c.moveToNext() at the end of the method is senseless
  3. Your variable results is never initialized

My advice: Remove every UI element from this class and start reading some links Pratik provided in his answer.


here is the good links to work with the sqlite with android with many controls

http://www.vogella.de/articles/AndroidListView/article.html

http://marakana.com/forums/android/examples/55.html

http://saigeethamn.blogspot.com/2009/10/android-developer-tutorial-part-12.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜