1

How can fetch values form database and display it in a textview in android?

1

2 Answers 2

1

Good to see you've given it some thought and tried on your own.

http://developer.android.com/guide/topics/data/data-storage.html#db has some good info on using SQLite on Android

It's also used in the Notepad tutorial: http://developer.android.com/resources/tutorials/notepad/notepad-ex1.html

I personally learned by using part of the guide from the "Hello, Android" book. The source code is available at: http://www.pragprog.com/titles/eband3/source_code - the SQL example is the one called 'Eventsv1'

Sign up to request clarification or add additional context in comments.

Comments

0

You need SQLiteOpenHelper class to fetch readable instance of SQLiteDatabase in android. Then using query method you can get Cursor object of you query.

Can you explain more about what you want to do? Try this,

Cursor c =  db.query(TABLE_NAME, columns, null, null, null, null, null);

Then write

if(c!=null) {
                c.moveToFirst();


                while(!c.isAfterLast()) {

                    String col1Value = c.getString(1);//here you get col1 value
                    String col2Value = c.getString(2);//here you get col2 value

                    c.moveToNext();

                }
                c.deactivate();
                c.close();
            }

1 Comment

i want to fetch data from the database by querying and display the feilds in different textviews.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.