This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//while moving cursor to the last, read 3rd column data (index 2) which in our database is (name - string) | |
while(c.moveToNext()){s2=c.getString(2);} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SQLiteDatabase readDB= db.getReadableDatabase(); | |
Cursor c = readDB.rawQuery("SELECT * from test", null); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create an instance of SQLiteDatabase using getWritableDatabase() | |
SQLiteDatabase writeDB = db.getWritableDatabase(); | |
// Use execSQL function to pass SQL insert statement to execute | |
writeDB.execSQL("INSERT into test (count, name) values(0,'sample')"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DbManager db = new DbManager(this.getApplicationContext()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DbManager extends SQLiteOpenHelper{ | |
//Database name | |
private static final String dbName = "sampleData"; | |
private static final Integer version = 1; | |
//initializer | |
public DbManager(Context context) { | |
super(context, dbName, null, version); | |
} | |