I'm new in android. I just write an app that give a string from EditText and save it in SQLite. know I want see the contents of Database in a ListView. But I don't Know how could you please help me to write a method for this work.
That's my DBManager class
package com.sara.app.savetextapp;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class DBManager extends SQLiteOpenHelper {
public static final String DB_NAME = "Data";
public static final String TABLE_NAME = "test";
public static final String COLUMN_NAME= "text";
private static final String COLUMN_TEXT_ID = "_id";
public DBManager(Context context) {
super(context, DB_NAME, null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE " + TABLE_NAME + " ("
+ COLUMN_TEXT_ID + " integer primary key autoincrement, "
+ COLUMN_NAME + " varchar(100))");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion){
db.execSQL("DROP TABLE IF EXISTS");
onCreate(db);
}
public Cursor getDetails()
{
SQLiteDatabase db = getReadableDatabase();
return db.rawQuery("select text from Data", null);
}
}