Note that there are some explanatory texts on larger screens.

plurals
  1. POGet data from database Android
    text
    copied!<p>I have a page which can retrieve user data from database but after whole day of trying, I am only able to get the table column name but not the value inside.</p> <p><strong>this is my code to create database</strong></p> <pre><code> public static final String LASTLOGIN = "lastuser"; public static final String USER_ID = "suser_id"; public static final String USER_NAME = "suser_name"; public static final String USER_PASSWORD = "spassword"; public static final String PRIME_ID = "id"; private static final String TABLE_USER = "create table "+ LASTLOGIN+" (" +PRIME_ID+" integer primary key autoincrement, " + USER_ID + " text, " + USER_NAME +" text, " +USER_PASSWORD+" text); "; </code></pre> <p><strong>and here is the function implemented to get user data</strong></p> <pre><code>public Cursor getuser() { String[] columns = new String[]{PRIME_ID, USER_NAME, USER_PASSWORD}; Cursor cursor = sqLiteDatabase.query( LASTLOGIN, columns, null, null, null, null, PRIME_ID +" DESC"); Log.d("TAG", columns[1]); return cursor; } </code></pre> <p><strong>and here is my code to display the result</strong></p> <pre><code>mySQLiteAdapter = new SQLiteAdapter(this); mySQLiteAdapter.openToWrite(); cursor = mySQLiteAdapter.getuser(); String[] resultvalue = new String{ SQLiteAdapter.PRIME_ID,SQLiteAdapter.USER_NAME, SQLiteAdapter.USER_PASSWORD}; Toast.makeText(this, resultvalue[0]+resultvalue[1], Toast.LENGTH_LONG).show(); </code></pre> <p>and the toast result only show the column name but not the value inside, is there any mistake i made? and I want to set limit to 1, but where to set it?</p> <p>Thanks for helping me</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload