Eugen
Eugen

Reputation: 1543

How to display Android database content?

I'm back with another question regarding Android databases.

I'm storing a simple string into my android database and then wish to display all the entries as a list. However, the list shows nothing on my emulator (or my actual device) and neither does LogCat (either when saving entries into the DB or when calling them).

Below you have my code

Thanks a lot for taking the time to look over this and help me out. I'm really stumped and don't know where to go from here...

Upvotes: 0

Views: 3189

Answers (2)

The iCoder
The iCoder

Reputation: 1444

Firstly, check that your database is created or not then check whether table is created or not , through command line. If all-things are OK then try to print cursor to check it retrieves data from db or not. for printing the cursor values use following logic..

 *if(!cursor.isAfterLast())
    {   
        cursor.moveToFirst();
        do{  
           String entry = cursor.getString(cursor.getColumnIndex(KEY_ENTRY));
          Log.v("value:",entry);
          cursor.moveToNext();
          }while(!cursor.isAfterLast());*

Upvotes: 1

Shaik Khader
Shaik Khader

Reputation: 387

Your code has no issue , will you please check in the database file weather the data is there one way is use sqlite browser (or) go through this in command prompt {$ adb shell $ cd data/data/projectname/databases/
check if your db file is created and then move on to --> sqlite3 database file name you will find the sqlite prompt- hence you can explore as .tables and select * from table Name }

the above steps are mentioned in view of newbees if you know this earlier please ignore

to explore the db file.

please check this https://stackoverflow.com/questions/2149438/tool-to-see-android-database-tables-and-data

Upvotes: 0

Related Questions