I have created a little demo app in which I've been trying to implement an SQLite Database. Everything is working, however being new to mobile development I'm not sure how the database works.
public class DBOpenHelper extends SQLiteOpenHelper{
//Constants for db name and version
private static final String DATABASE_NAME = "notes.db";
private static final int DATABASE_VERSION = 1;
//Constants for identifying table and columns
public static final String TABLE_NOTES = "notes";
public static final String NOTE_ID = "_id";
public static final String NOTE_TEXT = "noteText";
public static final String NOTE_CREATED = "noteCreated";
public static final String[] ALL_COLUMNS =
{NOTE_ID, NOTE_TEXT, NOTE_CREATED};
//SQL to create table
private static final String TABLE_CREATE =
"CREATE TABLE " + TABLE_NOTES + " (" +
NOTE_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
NOTE_TEXT + " TEXT, " +
NOTE_CREATED + " TEXT default CURRENT_TIMESTAMP" +
")";
public DBOpenHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(TABLE_CREATE);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " + TABLE_NOTES);
onCreate(db);
}
}
Will this database be the same database on all phones who downloads the app, which means if person 1 on a phone writes something to the database, person 2 with another phone will immediately see the update?
or is it the other way around: person 1 has one database and person 2 will have another database for himself?
I'm interested in creating a database for my app that works as one database for all the phones, so that person 1 and person 2 will use the exact same database.
AbstractThreadedSyncAdapter-- developer.android.com/reference/android/content/…