I have created database SQLite in Android Studio, and I inserted there some data using SQLite Manager plugin Mozilla Firefox. When I using virtual device I see all of it, but when I want to use new virtual device or smartphone new database is create and all data is lost. Can I somehow use only one created database with inserted data? I'm sorry for my writing.
public static final String DATABASE_NAME = "Database.db";
public static final String TABLE_NAME = "USER";
public static final String ID = "ID";
public static final String Name= "Name";
public static final String Surname= "Surname";
public static final String email= "email";
public BazaDanych(Context context) {
super(context, DATABASE_NAME, null, 1);
// SQLiteDatabase db = this.getWritableDatabase();
}
public void onCreate(SQLiteDatabase db) {
db.execSQL("create table " + TABLE_NAME + "(ID INTEGER PRIMARY KEY AUTOINCREMENT,Name VARCHAR(20),Surname VARCHAR,email VARCHAR)");}
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF NOT EXISTS "+ TABLE_NAME);
onCreate(db);}
Aucun commentaire:
Enregistrer un commentaire