Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try the following method, which is working perfectly for me and also easy to understand</p> <p>Create one separate class which extends SQLiteOpenHelper</p> <pre><code>public class DataBase extends SQLiteOpenHelper{ public static final String DATABASE_NAME = "Databasename"; public static final int DATABASE_VERSION = 1; public static final String SETTINGSID = BaseColumns._ID; public static final String ST_PHONENUMBER = "PhoneNumber"; public static final String ST_NAME = "Name"; public static final String ST_SECUREENABLED = "SecureSMS"; public DataBase(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); // TODO Auto-generated constructor stub } </code></pre> <p>In <code>onCreate()/onUpgrade()</code> method you can create/delete your table</p> <pre><code> @Override public void onCreate(SQLiteDatabase db) { String settings = "CREATE TABLE IF NOT EXISTS " + SETTINGS_TABLE + " (" + SETTINGSID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + ST_PHONENUMBER + " TEXT, " + ST_NAME + " TEXT, " + ST_SECUREENABLED + " TEXT"+ ");"; db.execSQL(settings); @Override public void onUpgrade(SQLiteDatabase db, int arg1, int arg2) { db.execSQL("DROP TABLE IF EXISTS " + SETTINGS_TABLE); db.execSQL("DROP TABLE IF EXISTS " + LOCATION_TABLE); onCreate(db); } </code></pre> <p>Insert values into database using the following method</p> <pre><code> public void insertSettings(String phonenumber, String name,String securenames) { SQLiteDatabase db = getReadableDatabase(); ContentValues values = new ContentValues(); values.put(ST_PHONENUMBER, phonenumber); values.put(ST_NAME, name); values.put(ST_SECUREENABLED, securenames); db.insertOrThrow(SETTINGS_TABLE, null, values); } </code></pre> <p>I hope this will guide in you in a right direction...</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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