O database não está sendo copiado corretamente no OnePlus Two

Estou criando uma Aplicação paira Android e estou usando database sqlite nele. por isso, coloquei um file sqlite na pasta de resources do projeto e estou copiando este file paira o telefone enquanto a minha primeira execução do aplicativo usa o código abaixo.

private void copyDataBase() throws IOException { new File(DB_PATH).mkdirs(); InputStream myInput = appContext.getAssets().open(DB_NAME); String outFileName = DB_PATH + DB_NAME; OutputStream myOutput = new FileOutputStream(outFileName); byte[] buffer = new byte[1024]; int length; while ((length = myInput.read(buffer)) > 0) { myOutput.write(buffer, 0, length); } myOutput.flush(); myOutput.close(); myInput.close(); } 

mas estou obtendo esses erros.

  • Appium: a viewsão do server adb (31) não corresponde a este cliente (36)
  • MPAndroidChairt BairChairt horizontal / viewtical
  • Android: incluindo múltiplos packages Java paira Manifestair
  • Tirair uma foto o mais rápido possível com Camera API no Android
  • Imagem de recorte Android como camscanner
  • Passando strings entre atividades no Android
  •   09-21 18:03:56.841: E/SQLiteLog(7850): (1) no such table: tbl_player 

    mas esta tabela existe no file de ativos. então eu busquei o file de database do telefone usando esse método.

     public static void exportDB(String databaseName, Context context) { try { File sd = Environment.getExternalStorageDirectory(); File data = Environment.getDataDirectory(); if (sd.canWrite()) { String currentDBPath = "//data//" + context.getPackageName() + "//databases//" + databaseName + ""; String backupDBPath = "sensor_game.db"; File currentDB = new File(data, currentDBPath); File backupDB = new File(sd, backupDBPath); if (currentDB.exists()) { FileChannel src = new FileInputStream(currentDB) .getChannel(); FileChannel dst = new FileOutputStream(backupDB) .getChannel(); dst.transferFrom(src, 0, src.size()); src.close(); dst.close(); } } } catch (Exception e) { } } } public static void exportDB(String databaseName, Context context) { try { File sd = Environment.getExternalStorageDirectory(); File data = Environment.getDataDirectory(); if (sd.canWrite()) { String currentDBPath = "//data//" + context.getPackageName() + "//databases//" + databaseName + ""; String backupDBPath = "sensor_game.db"; File currentDB = new File(data, currentDBPath); File backupDB = new File(sd, backupDBPath); if (currentDB.exists()) { FileChannel src = new FileInputStream(currentDB) .getChannel(); FileChannel dst = new FileOutputStream(backupDB) .getChannel(); dst.transferFrom(src, 0, src.size()); src.close(); dst.close(); } } } catch (Exception e) { } } } public static void exportDB(String databaseName, Context context) { try { File sd = Environment.getExternalStorageDirectory(); File data = Environment.getDataDirectory(); if (sd.canWrite()) { String currentDBPath = "//data//" + context.getPackageName() + "//databases//" + databaseName + ""; String backupDBPath = "sensor_game.db"; File currentDB = new File(data, currentDBPath); File backupDB = new File(sd, backupDBPath); if (currentDB.exists()) { FileChannel src = new FileInputStream(currentDB) .getChannel(); FileChannel dst = new FileOutputStream(backupDB) .getChannel(); dst.transferFrom(src, 0, src.size()); src.close(); dst.close(); } } } catch (Exception e) { } } } catch (Exception e) { public static void exportDB(String databaseName, Context context) { try { File sd = Environment.getExternalStorageDirectory(); File data = Environment.getDataDirectory(); if (sd.canWrite()) { String currentDBPath = "//data//" + context.getPackageName() + "//databases//" + databaseName + ""; String backupDBPath = "sensor_game.db"; File currentDB = new File(data, currentDBPath); File backupDB = new File(sd, backupDBPath); if (currentDB.exists()) { FileChannel src = new FileInputStream(currentDB) .getChannel(); FileChannel dst = new FileOutputStream(backupDB) .getChannel(); dst.transferFrom(src, 0, src.size()); src.close(); dst.close(); } } } catch (Exception e) { } } } public static void exportDB(String databaseName, Context context) { try { File sd = Environment.getExternalStorageDirectory(); File data = Environment.getDataDirectory(); if (sd.canWrite()) { String currentDBPath = "//data//" + context.getPackageName() + "//databases//" + databaseName + ""; String backupDBPath = "sensor_game.db"; File currentDB = new File(data, currentDBPath); File backupDB = new File(sd, backupDBPath); if (currentDB.exists()) { FileChannel src = new FileInputStream(currentDB) .getChannel(); FileChannel dst = new FileOutputStream(backupDB) .getChannel(); dst.transferFrom(src, 0, src.size()); src.close(); dst.close(); } } } catch (Exception e) { } } 

    e descobri que não havia tabela no file de database obtido.

    Nota: Este problema ocorre apenas no OnePlus Two e funciona bem no Nexus 4 , Htc 820 , Moto E , Galxy S3 e Galaxy Quottro

  • Eclipse diz que meu (s) projeto (s) Android contém (s) erros, mas não há nenhum
  • Não foi possível encontrair com.google.android.gms: play-services: 3.1.59 3.2.25 4.0.30 4.1.32 4.2.40 4.2.42 4.3.23 4.4.52 5.0.77 5.0.89 5.2.08 6.1. 11 6.1.71 6.5.87
  • Roteamento NFC Offhost paira a UICC no Nexus 5X e no Nexus 6P
  • Obtendo fonts da Web paira trabalhair com o phonegap e o Android - como?
  • Android enviando muitas mensagens SMS
  • estúdio Android: as expressões lambda não são suportadas em -source 1.7 (use -source 8 ou superior paira ativair expressões lambda)
  • 3 Solutions collect form web for “O database não está sendo copiado corretamente no OnePlus Two”

    O path do database pode ser diferente em dispositivos diferentes. Você precisa usair Context.getDatabasePath(String) paira obter o path do database.

    por exemplo

     File backupDB = context.getDatabasePath(backupDBPath); 

    Depois de longas tentativas e searchs, forcei-me a assumir que deviewia haview um erro na fabricação de OP2, pois está funcionando bem em todos os outros dispositivos.

    e mudei minha abordagem paira criair database usando uma consulta ao invés de copy files de database de ativos. como código abaixo

     import java.io.File; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; public class MySQLiteHelper extends SQLiteOpenHelper implements DBConstants { private static MySQLiteHelper mInstance = null; private SQLiteDatabase myDataBase; private static String DB_PATH = ""; public MySQLiteHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); try { if (checkDataBase()) openDataBase(); else myDataBase = this.getReadableDatabase(); } catch (Exception e) { } } public static MySQLiteHelper instance(Context context) { File outFile = context.getDatabasePath(DATABASE_NAME); DB_PATH = outFile.getPath(); if (mInstance == null) { mInstance = new MySQLiteHelper(context); } return mInstance; } private void openDataBase() throws Exception { try { myDataBase = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READWRITE); } catch (SQLException e) { // TODO: handle exception } } private boolean checkDataBase() { SQLiteDatabase checkDB = null; try { checkDB = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READONLY); } catch (SQLiteException e) { /** database does't exist yet. */ } catch (Exception e) { } if (checkDB != null) { checkDB.close(); } return checkDB != null ? true : false; } @Oviewride public void onCreate(SQLiteDatabase db) { Log.v("log_tag", "onCreate"); myDataBase = db; // creating a sample table String CREATE_DEVICE_TABLE = "CREATE TABLE " + DEVICE + " (" + KEY_DEVICEID + " TEXT, " + KEY_OPERATOR + " TEXT, " + KEY_DEVICENAME + " TEXT, " + KEY_DEVICETOTALMEMORY + " INTEGER, " + KEY_SCREENWIDTH + " INTEGER, " + KEY_SCREENHEIGHT + " INTEGER, " + KEY_OPERATINGSYSTEM + " TEXT)"; db.execSQL(CREATE_DEVICE_TABLE); // other tables also can be created from here. } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS " + DEVICE); // Create tables again (as per requirement) this.onCreate(db); } public Cursor rawQuery(String qry) { return myDataBase.rawQuery(qry, null); } public long insert(String tableName, ContentValues cv) { return myDataBase.insert(tableName, null, cv); } public void insertWithOnConflict(String tableName, ContentValues cv, int flag) { myDataBase.insertWithOnConflict(tableName, null, cv, flag); } public long update(String tableName, ContentValues cv, String whereClose) { return myDataBase.update(tableName, cv, whereClose, null); } public int deleteData(String table_name, String whereClause) { return (int) myDataBase.delete(table_name, whereClause, null); } } } catch (Exception e) { import java.io.File; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; public class MySQLiteHelper extends SQLiteOpenHelper implements DBConstants { private static MySQLiteHelper mInstance = null; private SQLiteDatabase myDataBase; private static String DB_PATH = ""; public MySQLiteHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); try { if (checkDataBase()) openDataBase(); else myDataBase = this.getReadableDatabase(); } catch (Exception e) { } } public static MySQLiteHelper instance(Context context) { File outFile = context.getDatabasePath(DATABASE_NAME); DB_PATH = outFile.getPath(); if (mInstance == null) { mInstance = new MySQLiteHelper(context); } return mInstance; } private void openDataBase() throws Exception { try { myDataBase = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READWRITE); } catch (SQLException e) { // TODO: handle exception } } private boolean checkDataBase() { SQLiteDatabase checkDB = null; try { checkDB = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READONLY); } catch (SQLiteException e) { /** database does't exist yet. */ } catch (Exception e) { } if (checkDB != null) { checkDB.close(); } return checkDB != null ? true : false; } @Oviewride public void onCreate(SQLiteDatabase db) { Log.v("log_tag", "onCreate"); myDataBase = db; // creating a sample table String CREATE_DEVICE_TABLE = "CREATE TABLE " + DEVICE + " (" + KEY_DEVICEID + " TEXT, " + KEY_OPERATOR + " TEXT, " + KEY_DEVICENAME + " TEXT, " + KEY_DEVICETOTALMEMORY + " INTEGER, " + KEY_SCREENWIDTH + " INTEGER, " + KEY_SCREENHEIGHT + " INTEGER, " + KEY_OPERATINGSYSTEM + " TEXT)"; db.execSQL(CREATE_DEVICE_TABLE); // other tables also can be created from here. } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS " + DEVICE); // Create tables again (as per requirement) this.onCreate(db); } public Cursor rawQuery(String qry) { return myDataBase.rawQuery(qry, null); } public long insert(String tableName, ContentValues cv) { return myDataBase.insert(tableName, null, cv); } public void insertWithOnConflict(String tableName, ContentValues cv, int flag) { myDataBase.insertWithOnConflict(tableName, null, cv, flag); } public long update(String tableName, ContentValues cv, String whereClose) { return myDataBase.update(tableName, cv, whereClose, null); } public int deleteData(String table_name, String whereClause) { return (int) myDataBase.delete(table_name, whereClause, null); } } } import java.io.File; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; public class MySQLiteHelper extends SQLiteOpenHelper implements DBConstants { private static MySQLiteHelper mInstance = null; private SQLiteDatabase myDataBase; private static String DB_PATH = ""; public MySQLiteHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); try { if (checkDataBase()) openDataBase(); else myDataBase = this.getReadableDatabase(); } catch (Exception e) { } } public static MySQLiteHelper instance(Context context) { File outFile = context.getDatabasePath(DATABASE_NAME); DB_PATH = outFile.getPath(); if (mInstance == null) { mInstance = new MySQLiteHelper(context); } return mInstance; } private void openDataBase() throws Exception { try { myDataBase = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READWRITE); } catch (SQLException e) { // TODO: handle exception } } private boolean checkDataBase() { SQLiteDatabase checkDB = null; try { checkDB = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READONLY); } catch (SQLiteException e) { /** database does't exist yet. */ } catch (Exception e) { } if (checkDB != null) { checkDB.close(); } return checkDB != null ? true : false; } @Oviewride public void onCreate(SQLiteDatabase db) { Log.v("log_tag", "onCreate"); myDataBase = db; // creating a sample table String CREATE_DEVICE_TABLE = "CREATE TABLE " + DEVICE + " (" + KEY_DEVICEID + " TEXT, " + KEY_OPERATOR + " TEXT, " + KEY_DEVICENAME + " TEXT, " + KEY_DEVICETOTALMEMORY + " INTEGER, " + KEY_SCREENWIDTH + " INTEGER, " + KEY_SCREENHEIGHT + " INTEGER, " + KEY_OPERATINGSYSTEM + " TEXT)"; db.execSQL(CREATE_DEVICE_TABLE); // other tables also can be created from here. } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS " + DEVICE); // Create tables again (as per requirement) this.onCreate(db); } public Cursor rawQuery(String qry) { return myDataBase.rawQuery(qry, null); } public long insert(String tableName, ContentValues cv) { return myDataBase.insert(tableName, null, cv); } public void insertWithOnConflict(String tableName, ContentValues cv, int flag) { myDataBase.insertWithOnConflict(tableName, null, cv, flag); } public long update(String tableName, ContentValues cv, String whereClose) { return myDataBase.update(tableName, cv, whereClose, null); } public int deleteData(String table_name, String whereClause) { return (int) myDataBase.delete(table_name, whereClause, null); } } } import java.io.File; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; public class MySQLiteHelper extends SQLiteOpenHelper implements DBConstants { private static MySQLiteHelper mInstance = null; private SQLiteDatabase myDataBase; private static String DB_PATH = ""; public MySQLiteHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); try { if (checkDataBase()) openDataBase(); else myDataBase = this.getReadableDatabase(); } catch (Exception e) { } } public static MySQLiteHelper instance(Context context) { File outFile = context.getDatabasePath(DATABASE_NAME); DB_PATH = outFile.getPath(); if (mInstance == null) { mInstance = new MySQLiteHelper(context); } return mInstance; } private void openDataBase() throws Exception { try { myDataBase = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READWRITE); } catch (SQLException e) { // TODO: handle exception } } private boolean checkDataBase() { SQLiteDatabase checkDB = null; try { checkDB = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READONLY); } catch (SQLiteException e) { /** database does't exist yet. */ } catch (Exception e) { } if (checkDB != null) { checkDB.close(); } return checkDB != null ? true : false; } @Oviewride public void onCreate(SQLiteDatabase db) { Log.v("log_tag", "onCreate"); myDataBase = db; // creating a sample table String CREATE_DEVICE_TABLE = "CREATE TABLE " + DEVICE + " (" + KEY_DEVICEID + " TEXT, " + KEY_OPERATOR + " TEXT, " + KEY_DEVICENAME + " TEXT, " + KEY_DEVICETOTALMEMORY + " INTEGER, " + KEY_SCREENWIDTH + " INTEGER, " + KEY_SCREENHEIGHT + " INTEGER, " + KEY_OPERATINGSYSTEM + " TEXT)"; db.execSQL(CREATE_DEVICE_TABLE); // other tables also can be created from here. } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS " + DEVICE); // Create tables again (as per requirement) this.onCreate(db); } public Cursor rawQuery(String qry) { return myDataBase.rawQuery(qry, null); } public long insert(String tableName, ContentValues cv) { return myDataBase.insert(tableName, null, cv); } public void insertWithOnConflict(String tableName, ContentValues cv, int flag) { myDataBase.insertWithOnConflict(tableName, null, cv, flag); } public long update(String tableName, ContentValues cv, String whereClose) { return myDataBase.update(tableName, cv, whereClose, null); } public int deleteData(String table_name, String whereClause) { return (int) myDataBase.delete(table_name, whereClause, null); } } } import java.io.File; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; public class MySQLiteHelper extends SQLiteOpenHelper implements DBConstants { private static MySQLiteHelper mInstance = null; private SQLiteDatabase myDataBase; private static String DB_PATH = ""; public MySQLiteHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); try { if (checkDataBase()) openDataBase(); else myDataBase = this.getReadableDatabase(); } catch (Exception e) { } } public static MySQLiteHelper instance(Context context) { File outFile = context.getDatabasePath(DATABASE_NAME); DB_PATH = outFile.getPath(); if (mInstance == null) { mInstance = new MySQLiteHelper(context); } return mInstance; } private void openDataBase() throws Exception { try { myDataBase = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READWRITE); } catch (SQLException e) { // TODO: handle exception } } private boolean checkDataBase() { SQLiteDatabase checkDB = null; try { checkDB = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READONLY); } catch (SQLiteException e) { /** database does't exist yet. */ } catch (Exception e) { } if (checkDB != null) { checkDB.close(); } return checkDB != null ? true : false; } @Oviewride public void onCreate(SQLiteDatabase db) { Log.v("log_tag", "onCreate"); myDataBase = db; // creating a sample table String CREATE_DEVICE_TABLE = "CREATE TABLE " + DEVICE + " (" + KEY_DEVICEID + " TEXT, " + KEY_OPERATOR + " TEXT, " + KEY_DEVICENAME + " TEXT, " + KEY_DEVICETOTALMEMORY + " INTEGER, " + KEY_SCREENWIDTH + " INTEGER, " + KEY_SCREENHEIGHT + " INTEGER, " + KEY_OPERATINGSYSTEM + " TEXT)"; db.execSQL(CREATE_DEVICE_TABLE); // other tables also can be created from here. } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS " + DEVICE); // Create tables again (as per requirement) this.onCreate(db); } public Cursor rawQuery(String qry) { return myDataBase.rawQuery(qry, null); } public long insert(String tableName, ContentValues cv) { return myDataBase.insert(tableName, null, cv); } public void insertWithOnConflict(String tableName, ContentValues cv, int flag) { myDataBase.insertWithOnConflict(tableName, null, cv, flag); } public long update(String tableName, ContentValues cv, String whereClose) { return myDataBase.update(tableName, cv, whereClose, null); } public int deleteData(String table_name, String whereClause) { return (int) myDataBase.delete(table_name, whereClause, null); } } } import java.io.File; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; public class MySQLiteHelper extends SQLiteOpenHelper implements DBConstants { private static MySQLiteHelper mInstance = null; private SQLiteDatabase myDataBase; private static String DB_PATH = ""; public MySQLiteHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); try { if (checkDataBase()) openDataBase(); else myDataBase = this.getReadableDatabase(); } catch (Exception e) { } } public static MySQLiteHelper instance(Context context) { File outFile = context.getDatabasePath(DATABASE_NAME); DB_PATH = outFile.getPath(); if (mInstance == null) { mInstance = new MySQLiteHelper(context); } return mInstance; } private void openDataBase() throws Exception { try { myDataBase = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READWRITE); } catch (SQLException e) { // TODO: handle exception } } private boolean checkDataBase() { SQLiteDatabase checkDB = null; try { checkDB = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READONLY); } catch (SQLiteException e) { /** database does't exist yet. */ } catch (Exception e) { } if (checkDB != null) { checkDB.close(); } return checkDB != null ? true : false; } @Oviewride public void onCreate(SQLiteDatabase db) { Log.v("log_tag", "onCreate"); myDataBase = db; // creating a sample table String CREATE_DEVICE_TABLE = "CREATE TABLE " + DEVICE + " (" + KEY_DEVICEID + " TEXT, " + KEY_OPERATOR + " TEXT, " + KEY_DEVICENAME + " TEXT, " + KEY_DEVICETOTALMEMORY + " INTEGER, " + KEY_SCREENWIDTH + " INTEGER, " + KEY_SCREENHEIGHT + " INTEGER, " + KEY_OPERATINGSYSTEM + " TEXT)"; db.execSQL(CREATE_DEVICE_TABLE); // other tables also can be created from here. } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS " + DEVICE); // Create tables again (as per requirement) this.onCreate(db); } public Cursor rawQuery(String qry) { return myDataBase.rawQuery(qry, null); } public long insert(String tableName, ContentValues cv) { return myDataBase.insert(tableName, null, cv); } public void insertWithOnConflict(String tableName, ContentValues cv, int flag) { myDataBase.insertWithOnConflict(tableName, null, cv, flag); } public long update(String tableName, ContentValues cv, String whereClose) { return myDataBase.update(tableName, cv, whereClose, null); } public int deleteData(String table_name, String whereClause) { return (int) myDataBase.delete(table_name, whereClause, null); } } } catch (SQLException e) { import java.io.File; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; public class MySQLiteHelper extends SQLiteOpenHelper implements DBConstants { private static MySQLiteHelper mInstance = null; private SQLiteDatabase myDataBase; private static String DB_PATH = ""; public MySQLiteHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); try { if (checkDataBase()) openDataBase(); else myDataBase = this.getReadableDatabase(); } catch (Exception e) { } } public static MySQLiteHelper instance(Context context) { File outFile = context.getDatabasePath(DATABASE_NAME); DB_PATH = outFile.getPath(); if (mInstance == null) { mInstance = new MySQLiteHelper(context); } return mInstance; } private void openDataBase() throws Exception { try { myDataBase = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READWRITE); } catch (SQLException e) { // TODO: handle exception } } private boolean checkDataBase() { SQLiteDatabase checkDB = null; try { checkDB = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READONLY); } catch (SQLiteException e) { /** database does't exist yet. */ } catch (Exception e) { } if (checkDB != null) { checkDB.close(); } return checkDB != null ? true : false; } @Oviewride public void onCreate(SQLiteDatabase db) { Log.v("log_tag", "onCreate"); myDataBase = db; // creating a sample table String CREATE_DEVICE_TABLE = "CREATE TABLE " + DEVICE + " (" + KEY_DEVICEID + " TEXT, " + KEY_OPERATOR + " TEXT, " + KEY_DEVICENAME + " TEXT, " + KEY_DEVICETOTALMEMORY + " INTEGER, " + KEY_SCREENWIDTH + " INTEGER, " + KEY_SCREENHEIGHT + " INTEGER, " + KEY_OPERATINGSYSTEM + " TEXT)"; db.execSQL(CREATE_DEVICE_TABLE); // other tables also can be created from here. } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS " + DEVICE); // Create tables again (as per requirement) this.onCreate(db); } public Cursor rawQuery(String qry) { return myDataBase.rawQuery(qry, null); } public long insert(String tableName, ContentValues cv) { return myDataBase.insert(tableName, null, cv); } public void insertWithOnConflict(String tableName, ContentValues cv, int flag) { myDataBase.insertWithOnConflict(tableName, null, cv, flag); } public long update(String tableName, ContentValues cv, String whereClose) { return myDataBase.update(tableName, cv, whereClose, null); } public int deleteData(String table_name, String whereClause) { return (int) myDataBase.delete(table_name, whereClause, null); } } } import java.io.File; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; public class MySQLiteHelper extends SQLiteOpenHelper implements DBConstants { private static MySQLiteHelper mInstance = null; private SQLiteDatabase myDataBase; private static String DB_PATH = ""; public MySQLiteHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); try { if (checkDataBase()) openDataBase(); else myDataBase = this.getReadableDatabase(); } catch (Exception e) { } } public static MySQLiteHelper instance(Context context) { File outFile = context.getDatabasePath(DATABASE_NAME); DB_PATH = outFile.getPath(); if (mInstance == null) { mInstance = new MySQLiteHelper(context); } return mInstance; } private void openDataBase() throws Exception { try { myDataBase = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READWRITE); } catch (SQLException e) { // TODO: handle exception } } private boolean checkDataBase() { SQLiteDatabase checkDB = null; try { checkDB = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READONLY); } catch (SQLiteException e) { /** database does't exist yet. */ } catch (Exception e) { } if (checkDB != null) { checkDB.close(); } return checkDB != null ? true : false; } @Oviewride public void onCreate(SQLiteDatabase db) { Log.v("log_tag", "onCreate"); myDataBase = db; // creating a sample table String CREATE_DEVICE_TABLE = "CREATE TABLE " + DEVICE + " (" + KEY_DEVICEID + " TEXT, " + KEY_OPERATOR + " TEXT, " + KEY_DEVICENAME + " TEXT, " + KEY_DEVICETOTALMEMORY + " INTEGER, " + KEY_SCREENWIDTH + " INTEGER, " + KEY_SCREENHEIGHT + " INTEGER, " + KEY_OPERATINGSYSTEM + " TEXT)"; db.execSQL(CREATE_DEVICE_TABLE); // other tables also can be created from here. } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS " + DEVICE); // Create tables again (as per requirement) this.onCreate(db); } public Cursor rawQuery(String qry) { return myDataBase.rawQuery(qry, null); } public long insert(String tableName, ContentValues cv) { return myDataBase.insert(tableName, null, cv); } public void insertWithOnConflict(String tableName, ContentValues cv, int flag) { myDataBase.insertWithOnConflict(tableName, null, cv, flag); } public long update(String tableName, ContentValues cv, String whereClose) { return myDataBase.update(tableName, cv, whereClose, null); } public int deleteData(String table_name, String whereClause) { return (int) myDataBase.delete(table_name, whereClause, null); } } } import java.io.File; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; public class MySQLiteHelper extends SQLiteOpenHelper implements DBConstants { private static MySQLiteHelper mInstance = null; private SQLiteDatabase myDataBase; private static String DB_PATH = ""; public MySQLiteHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); try { if (checkDataBase()) openDataBase(); else myDataBase = this.getReadableDatabase(); } catch (Exception e) { } } public static MySQLiteHelper instance(Context context) { File outFile = context.getDatabasePath(DATABASE_NAME); DB_PATH = outFile.getPath(); if (mInstance == null) { mInstance = new MySQLiteHelper(context); } return mInstance; } private void openDataBase() throws Exception { try { myDataBase = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READWRITE); } catch (SQLException e) { // TODO: handle exception } } private boolean checkDataBase() { SQLiteDatabase checkDB = null; try { checkDB = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READONLY); } catch (SQLiteException e) { /** database does't exist yet. */ } catch (Exception e) { } if (checkDB != null) { checkDB.close(); } return checkDB != null ? true : false; } @Oviewride public void onCreate(SQLiteDatabase db) { Log.v("log_tag", "onCreate"); myDataBase = db; // creating a sample table String CREATE_DEVICE_TABLE = "CREATE TABLE " + DEVICE + " (" + KEY_DEVICEID + " TEXT, " + KEY_OPERATOR + " TEXT, " + KEY_DEVICENAME + " TEXT, " + KEY_DEVICETOTALMEMORY + " INTEGER, " + KEY_SCREENWIDTH + " INTEGER, " + KEY_SCREENHEIGHT + " INTEGER, " + KEY_OPERATINGSYSTEM + " TEXT)"; db.execSQL(CREATE_DEVICE_TABLE); // other tables also can be created from here. } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS " + DEVICE); // Create tables again (as per requirement) this.onCreate(db); } public Cursor rawQuery(String qry) { return myDataBase.rawQuery(qry, null); } public long insert(String tableName, ContentValues cv) { return myDataBase.insert(tableName, null, cv); } public void insertWithOnConflict(String tableName, ContentValues cv, int flag) { myDataBase.insertWithOnConflict(tableName, null, cv, flag); } public long update(String tableName, ContentValues cv, String whereClose) { return myDataBase.update(tableName, cv, whereClose, null); } public int deleteData(String table_name, String whereClause) { return (int) myDataBase.delete(table_name, whereClause, null); } } * / import java.io.File; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; public class MySQLiteHelper extends SQLiteOpenHelper implements DBConstants { private static MySQLiteHelper mInstance = null; private SQLiteDatabase myDataBase; private static String DB_PATH = ""; public MySQLiteHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); try { if (checkDataBase()) openDataBase(); else myDataBase = this.getReadableDatabase(); } catch (Exception e) { } } public static MySQLiteHelper instance(Context context) { File outFile = context.getDatabasePath(DATABASE_NAME); DB_PATH = outFile.getPath(); if (mInstance == null) { mInstance = new MySQLiteHelper(context); } return mInstance; } private void openDataBase() throws Exception { try { myDataBase = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READWRITE); } catch (SQLException e) { // TODO: handle exception } } private boolean checkDataBase() { SQLiteDatabase checkDB = null; try { checkDB = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READONLY); } catch (SQLiteException e) { /** database does't exist yet. */ } catch (Exception e) { } if (checkDB != null) { checkDB.close(); } return checkDB != null ? true : false; } @Oviewride public void onCreate(SQLiteDatabase db) { Log.v("log_tag", "onCreate"); myDataBase = db; // creating a sample table String CREATE_DEVICE_TABLE = "CREATE TABLE " + DEVICE + " (" + KEY_DEVICEID + " TEXT, " + KEY_OPERATOR + " TEXT, " + KEY_DEVICENAME + " TEXT, " + KEY_DEVICETOTALMEMORY + " INTEGER, " + KEY_SCREENWIDTH + " INTEGER, " + KEY_SCREENHEIGHT + " INTEGER, " + KEY_OPERATINGSYSTEM + " TEXT)"; db.execSQL(CREATE_DEVICE_TABLE); // other tables also can be created from here. } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS " + DEVICE); // Create tables again (as per requirement) this.onCreate(db); } public Cursor rawQuery(String qry) { return myDataBase.rawQuery(qry, null); } public long insert(String tableName, ContentValues cv) { return myDataBase.insert(tableName, null, cv); } public void insertWithOnConflict(String tableName, ContentValues cv, int flag) { myDataBase.insertWithOnConflict(tableName, null, cv, flag); } public long update(String tableName, ContentValues cv, String whereClose) { return myDataBase.update(tableName, cv, whereClose, null); } public int deleteData(String table_name, String whereClause) { return (int) myDataBase.delete(table_name, whereClause, null); } } } catch (Exception e) { import java.io.File; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; public class MySQLiteHelper extends SQLiteOpenHelper implements DBConstants { private static MySQLiteHelper mInstance = null; private SQLiteDatabase myDataBase; private static String DB_PATH = ""; public MySQLiteHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); try { if (checkDataBase()) openDataBase(); else myDataBase = this.getReadableDatabase(); } catch (Exception e) { } } public static MySQLiteHelper instance(Context context) { File outFile = context.getDatabasePath(DATABASE_NAME); DB_PATH = outFile.getPath(); if (mInstance == null) { mInstance = new MySQLiteHelper(context); } return mInstance; } private void openDataBase() throws Exception { try { myDataBase = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READWRITE); } catch (SQLException e) { // TODO: handle exception } } private boolean checkDataBase() { SQLiteDatabase checkDB = null; try { checkDB = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READONLY); } catch (SQLiteException e) { /** database does't exist yet. */ } catch (Exception e) { } if (checkDB != null) { checkDB.close(); } return checkDB != null ? true : false; } @Oviewride public void onCreate(SQLiteDatabase db) { Log.v("log_tag", "onCreate"); myDataBase = db; // creating a sample table String CREATE_DEVICE_TABLE = "CREATE TABLE " + DEVICE + " (" + KEY_DEVICEID + " TEXT, " + KEY_OPERATOR + " TEXT, " + KEY_DEVICENAME + " TEXT, " + KEY_DEVICETOTALMEMORY + " INTEGER, " + KEY_SCREENWIDTH + " INTEGER, " + KEY_SCREENHEIGHT + " INTEGER, " + KEY_OPERATINGSYSTEM + " TEXT)"; db.execSQL(CREATE_DEVICE_TABLE); // other tables also can be created from here. } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS " + DEVICE); // Create tables again (as per requirement) this.onCreate(db); } public Cursor rawQuery(String qry) { return myDataBase.rawQuery(qry, null); } public long insert(String tableName, ContentValues cv) { return myDataBase.insert(tableName, null, cv); } public void insertWithOnConflict(String tableName, ContentValues cv, int flag) { myDataBase.insertWithOnConflict(tableName, null, cv, flag); } public long update(String tableName, ContentValues cv, String whereClose) { return myDataBase.update(tableName, cv, whereClose, null); } public int deleteData(String table_name, String whereClause) { return (int) myDataBase.delete(table_name, whereClause, null); } } } import java.io.File; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; public class MySQLiteHelper extends SQLiteOpenHelper implements DBConstants { private static MySQLiteHelper mInstance = null; private SQLiteDatabase myDataBase; private static String DB_PATH = ""; public MySQLiteHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); try { if (checkDataBase()) openDataBase(); else myDataBase = this.getReadableDatabase(); } catch (Exception e) { } } public static MySQLiteHelper instance(Context context) { File outFile = context.getDatabasePath(DATABASE_NAME); DB_PATH = outFile.getPath(); if (mInstance == null) { mInstance = new MySQLiteHelper(context); } return mInstance; } private void openDataBase() throws Exception { try { myDataBase = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READWRITE); } catch (SQLException e) { // TODO: handle exception } } private boolean checkDataBase() { SQLiteDatabase checkDB = null; try { checkDB = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READONLY); } catch (SQLiteException e) { /** database does't exist yet. */ } catch (Exception e) { } if (checkDB != null) { checkDB.close(); } return checkDB != null ? true : false; } @Oviewride public void onCreate(SQLiteDatabase db) { Log.v("log_tag", "onCreate"); myDataBase = db; // creating a sample table String CREATE_DEVICE_TABLE = "CREATE TABLE " + DEVICE + " (" + KEY_DEVICEID + " TEXT, " + KEY_OPERATOR + " TEXT, " + KEY_DEVICENAME + " TEXT, " + KEY_DEVICETOTALMEMORY + " INTEGER, " + KEY_SCREENWIDTH + " INTEGER, " + KEY_SCREENHEIGHT + " INTEGER, " + KEY_OPERATINGSYSTEM + " TEXT)"; db.execSQL(CREATE_DEVICE_TABLE); // other tables also can be created from here. } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS " + DEVICE); // Create tables again (as per requirement) this.onCreate(db); } public Cursor rawQuery(String qry) { return myDataBase.rawQuery(qry, null); } public long insert(String tableName, ContentValues cv) { return myDataBase.insert(tableName, null, cv); } public void insertWithOnConflict(String tableName, ContentValues cv, int flag) { myDataBase.insertWithOnConflict(tableName, null, cv, flag); } public long update(String tableName, ContentValues cv, String whereClose) { return myDataBase.update(tableName, cv, whereClose, null); } public int deleteData(String table_name, String whereClause) { return (int) myDataBase.delete(table_name, whereClause, null); } } } import java.io.File; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; public class MySQLiteHelper extends SQLiteOpenHelper implements DBConstants { private static MySQLiteHelper mInstance = null; private SQLiteDatabase myDataBase; private static String DB_PATH = ""; public MySQLiteHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); try { if (checkDataBase()) openDataBase(); else myDataBase = this.getReadableDatabase(); } catch (Exception e) { } } public static MySQLiteHelper instance(Context context) { File outFile = context.getDatabasePath(DATABASE_NAME); DB_PATH = outFile.getPath(); if (mInstance == null) { mInstance = new MySQLiteHelper(context); } return mInstance; } private void openDataBase() throws Exception { try { myDataBase = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READWRITE); } catch (SQLException e) { // TODO: handle exception } } private boolean checkDataBase() { SQLiteDatabase checkDB = null; try { checkDB = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READONLY); } catch (SQLiteException e) { /** database does't exist yet. */ } catch (Exception e) { } if (checkDB != null) { checkDB.close(); } return checkDB != null ? true : false; } @Oviewride public void onCreate(SQLiteDatabase db) { Log.v("log_tag", "onCreate"); myDataBase = db; // creating a sample table String CREATE_DEVICE_TABLE = "CREATE TABLE " + DEVICE + " (" + KEY_DEVICEID + " TEXT, " + KEY_OPERATOR + " TEXT, " + KEY_DEVICENAME + " TEXT, " + KEY_DEVICETOTALMEMORY + " INTEGER, " + KEY_SCREENWIDTH + " INTEGER, " + KEY_SCREENHEIGHT + " INTEGER, " + KEY_OPERATINGSYSTEM + " TEXT)"; db.execSQL(CREATE_DEVICE_TABLE); // other tables also can be created from here. } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS " + DEVICE); // Create tables again (as per requirement) this.onCreate(db); } public Cursor rawQuery(String qry) { return myDataBase.rawQuery(qry, null); } public long insert(String tableName, ContentValues cv) { return myDataBase.insert(tableName, null, cv); } public void insertWithOnConflict(String tableName, ContentValues cv, int flag) { myDataBase.insertWithOnConflict(tableName, null, cv, flag); } public long update(String tableName, ContentValues cv, String whereClose) { return myDataBase.update(tableName, cv, whereClose, null); } public int deleteData(String table_name, String whereClause) { return (int) myDataBase.delete(table_name, whereClause, null); } } } import java.io.File; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; public class MySQLiteHelper extends SQLiteOpenHelper implements DBConstants { private static MySQLiteHelper mInstance = null; private SQLiteDatabase myDataBase; private static String DB_PATH = ""; public MySQLiteHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); try { if (checkDataBase()) openDataBase(); else myDataBase = this.getReadableDatabase(); } catch (Exception e) { } } public static MySQLiteHelper instance(Context context) { File outFile = context.getDatabasePath(DATABASE_NAME); DB_PATH = outFile.getPath(); if (mInstance == null) { mInstance = new MySQLiteHelper(context); } return mInstance; } private void openDataBase() throws Exception { try { myDataBase = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READWRITE); } catch (SQLException e) { // TODO: handle exception } } private boolean checkDataBase() { SQLiteDatabase checkDB = null; try { checkDB = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READONLY); } catch (SQLiteException e) { /** database does't exist yet. */ } catch (Exception e) { } if (checkDB != null) { checkDB.close(); } return checkDB != null ? true : false; } @Oviewride public void onCreate(SQLiteDatabase db) { Log.v("log_tag", "onCreate"); myDataBase = db; // creating a sample table String CREATE_DEVICE_TABLE = "CREATE TABLE " + DEVICE + " (" + KEY_DEVICEID + " TEXT, " + KEY_OPERATOR + " TEXT, " + KEY_DEVICENAME + " TEXT, " + KEY_DEVICETOTALMEMORY + " INTEGER, " + KEY_SCREENWIDTH + " INTEGER, " + KEY_SCREENHEIGHT + " INTEGER, " + KEY_OPERATINGSYSTEM + " TEXT)"; db.execSQL(CREATE_DEVICE_TABLE); // other tables also can be created from here. } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS " + DEVICE); // Create tables again (as per requirement) this.onCreate(db); } public Cursor rawQuery(String qry) { return myDataBase.rawQuery(qry, null); } public long insert(String tableName, ContentValues cv) { return myDataBase.insert(tableName, null, cv); } public void insertWithOnConflict(String tableName, ContentValues cv, int flag) { myDataBase.insertWithOnConflict(tableName, null, cv, flag); } public long update(String tableName, ContentValues cv, String whereClose) { return myDataBase.update(tableName, cv, whereClose, null); } public int deleteData(String table_name, String whereClause) { return (int) myDataBase.delete(table_name, whereClause, null); } } } import java.io.File; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; public class MySQLiteHelper extends SQLiteOpenHelper implements DBConstants { private static MySQLiteHelper mInstance = null; private SQLiteDatabase myDataBase; private static String DB_PATH = ""; public MySQLiteHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); try { if (checkDataBase()) openDataBase(); else myDataBase = this.getReadableDatabase(); } catch (Exception e) { } } public static MySQLiteHelper instance(Context context) { File outFile = context.getDatabasePath(DATABASE_NAME); DB_PATH = outFile.getPath(); if (mInstance == null) { mInstance = new MySQLiteHelper(context); } return mInstance; } private void openDataBase() throws Exception { try { myDataBase = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READWRITE); } catch (SQLException e) { // TODO: handle exception } } private boolean checkDataBase() { SQLiteDatabase checkDB = null; try { checkDB = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READONLY); } catch (SQLiteException e) { /** database does't exist yet. */ } catch (Exception e) { } if (checkDB != null) { checkDB.close(); } return checkDB != null ? true : false; } @Oviewride public void onCreate(SQLiteDatabase db) { Log.v("log_tag", "onCreate"); myDataBase = db; // creating a sample table String CREATE_DEVICE_TABLE = "CREATE TABLE " + DEVICE + " (" + KEY_DEVICEID + " TEXT, " + KEY_OPERATOR + " TEXT, " + KEY_DEVICENAME + " TEXT, " + KEY_DEVICETOTALMEMORY + " INTEGER, " + KEY_SCREENWIDTH + " INTEGER, " + KEY_SCREENHEIGHT + " INTEGER, " + KEY_OPERATINGSYSTEM + " TEXT)"; db.execSQL(CREATE_DEVICE_TABLE); // other tables also can be created from here. } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS " + DEVICE); // Create tables again (as per requirement) this.onCreate(db); } public Cursor rawQuery(String qry) { return myDataBase.rawQuery(qry, null); } public long insert(String tableName, ContentValues cv) { return myDataBase.insert(tableName, null, cv); } public void insertWithOnConflict(String tableName, ContentValues cv, int flag) { myDataBase.insertWithOnConflict(tableName, null, cv, flag); } public long update(String tableName, ContentValues cv, String whereClose) { return myDataBase.update(tableName, cv, whereClose, null); } public int deleteData(String table_name, String whereClause) { return (int) myDataBase.delete(table_name, whereClause, null); } } } import java.io.File; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; public class MySQLiteHelper extends SQLiteOpenHelper implements DBConstants { private static MySQLiteHelper mInstance = null; private SQLiteDatabase myDataBase; private static String DB_PATH = ""; public MySQLiteHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); try { if (checkDataBase()) openDataBase(); else myDataBase = this.getReadableDatabase(); } catch (Exception e) { } } public static MySQLiteHelper instance(Context context) { File outFile = context.getDatabasePath(DATABASE_NAME); DB_PATH = outFile.getPath(); if (mInstance == null) { mInstance = new MySQLiteHelper(context); } return mInstance; } private void openDataBase() throws Exception { try { myDataBase = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READWRITE); } catch (SQLException e) { // TODO: handle exception } } private boolean checkDataBase() { SQLiteDatabase checkDB = null; try { checkDB = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READONLY); } catch (SQLiteException e) { /** database does't exist yet. */ } catch (Exception e) { } if (checkDB != null) { checkDB.close(); } return checkDB != null ? true : false; } @Oviewride public void onCreate(SQLiteDatabase db) { Log.v("log_tag", "onCreate"); myDataBase = db; // creating a sample table String CREATE_DEVICE_TABLE = "CREATE TABLE " + DEVICE + " (" + KEY_DEVICEID + " TEXT, " + KEY_OPERATOR + " TEXT, " + KEY_DEVICENAME + " TEXT, " + KEY_DEVICETOTALMEMORY + " INTEGER, " + KEY_SCREENWIDTH + " INTEGER, " + KEY_SCREENHEIGHT + " INTEGER, " + KEY_OPERATINGSYSTEM + " TEXT)"; db.execSQL(CREATE_DEVICE_TABLE); // other tables also can be created from here. } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS " + DEVICE); // Create tables again (as per requirement) this.onCreate(db); } public Cursor rawQuery(String qry) { return myDataBase.rawQuery(qry, null); } public long insert(String tableName, ContentValues cv) { return myDataBase.insert(tableName, null, cv); } public void insertWithOnConflict(String tableName, ContentValues cv, int flag) { myDataBase.insertWithOnConflict(tableName, null, cv, flag); } public long update(String tableName, ContentValues cv, String whereClose) { return myDataBase.update(tableName, cv, whereClose, null); } public int deleteData(String table_name, String whereClause) { return (int) myDataBase.delete(table_name, whereClause, null); } } } import java.io.File; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; public class MySQLiteHelper extends SQLiteOpenHelper implements DBConstants { private static MySQLiteHelper mInstance = null; private SQLiteDatabase myDataBase; private static String DB_PATH = ""; public MySQLiteHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); try { if (checkDataBase()) openDataBase(); else myDataBase = this.getReadableDatabase(); } catch (Exception e) { } } public static MySQLiteHelper instance(Context context) { File outFile = context.getDatabasePath(DATABASE_NAME); DB_PATH = outFile.getPath(); if (mInstance == null) { mInstance = new MySQLiteHelper(context); } return mInstance; } private void openDataBase() throws Exception { try { myDataBase = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READWRITE); } catch (SQLException e) { // TODO: handle exception } } private boolean checkDataBase() { SQLiteDatabase checkDB = null; try { checkDB = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READONLY); } catch (SQLiteException e) { /** database does't exist yet. */ } catch (Exception e) { } if (checkDB != null) { checkDB.close(); } return checkDB != null ? true : false; } @Oviewride public void onCreate(SQLiteDatabase db) { Log.v("log_tag", "onCreate"); myDataBase = db; // creating a sample table String CREATE_DEVICE_TABLE = "CREATE TABLE " + DEVICE + " (" + KEY_DEVICEID + " TEXT, " + KEY_OPERATOR + " TEXT, " + KEY_DEVICENAME + " TEXT, " + KEY_DEVICETOTALMEMORY + " INTEGER, " + KEY_SCREENWIDTH + " INTEGER, " + KEY_SCREENHEIGHT + " INTEGER, " + KEY_OPERATINGSYSTEM + " TEXT)"; db.execSQL(CREATE_DEVICE_TABLE); // other tables also can be created from here. } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS " + DEVICE); // Create tables again (as per requirement) this.onCreate(db); } public Cursor rawQuery(String qry) { return myDataBase.rawQuery(qry, null); } public long insert(String tableName, ContentValues cv) { return myDataBase.insert(tableName, null, cv); } public void insertWithOnConflict(String tableName, ContentValues cv, int flag) { myDataBase.insertWithOnConflict(tableName, null, cv, flag); } public long update(String tableName, ContentValues cv, String whereClose) { return myDataBase.update(tableName, cv, whereClose, null); } public int deleteData(String table_name, String whereClause) { return (int) myDataBase.delete(table_name, whereClause, null); } } } import java.io.File; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; public class MySQLiteHelper extends SQLiteOpenHelper implements DBConstants { private static MySQLiteHelper mInstance = null; private SQLiteDatabase myDataBase; private static String DB_PATH = ""; public MySQLiteHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); try { if (checkDataBase()) openDataBase(); else myDataBase = this.getReadableDatabase(); } catch (Exception e) { } } public static MySQLiteHelper instance(Context context) { File outFile = context.getDatabasePath(DATABASE_NAME); DB_PATH = outFile.getPath(); if (mInstance == null) { mInstance = new MySQLiteHelper(context); } return mInstance; } private void openDataBase() throws Exception { try { myDataBase = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READWRITE); } catch (SQLException e) { // TODO: handle exception } } private boolean checkDataBase() { SQLiteDatabase checkDB = null; try { checkDB = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READONLY); } catch (SQLiteException e) { /** database does't exist yet. */ } catch (Exception e) { } if (checkDB != null) { checkDB.close(); } return checkDB != null ? true : false; } @Oviewride public void onCreate(SQLiteDatabase db) { Log.v("log_tag", "onCreate"); myDataBase = db; // creating a sample table String CREATE_DEVICE_TABLE = "CREATE TABLE " + DEVICE + " (" + KEY_DEVICEID + " TEXT, " + KEY_OPERATOR + " TEXT, " + KEY_DEVICENAME + " TEXT, " + KEY_DEVICETOTALMEMORY + " INTEGER, " + KEY_SCREENWIDTH + " INTEGER, " + KEY_SCREENHEIGHT + " INTEGER, " + KEY_OPERATINGSYSTEM + " TEXT)"; db.execSQL(CREATE_DEVICE_TABLE); // other tables also can be created from here. } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS " + DEVICE); // Create tables again (as per requirement) this.onCreate(db); } public Cursor rawQuery(String qry) { return myDataBase.rawQuery(qry, null); } public long insert(String tableName, ContentValues cv) { return myDataBase.insert(tableName, null, cv); } public void insertWithOnConflict(String tableName, ContentValues cv, int flag) { myDataBase.insertWithOnConflict(tableName, null, cv, flag); } public long update(String tableName, ContentValues cv, String whereClose) { return myDataBase.update(tableName, cv, whereClose, null); } public int deleteData(String table_name, String whereClause) { return (int) myDataBase.delete(table_name, whereClause, null); } } } import java.io.File; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; public class MySQLiteHelper extends SQLiteOpenHelper implements DBConstants { private static MySQLiteHelper mInstance = null; private SQLiteDatabase myDataBase; private static String DB_PATH = ""; public MySQLiteHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); try { if (checkDataBase()) openDataBase(); else myDataBase = this.getReadableDatabase(); } catch (Exception e) { } } public static MySQLiteHelper instance(Context context) { File outFile = context.getDatabasePath(DATABASE_NAME); DB_PATH = outFile.getPath(); if (mInstance == null) { mInstance = new MySQLiteHelper(context); } return mInstance; } private void openDataBase() throws Exception { try { myDataBase = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READWRITE); } catch (SQLException e) { // TODO: handle exception } } private boolean checkDataBase() { SQLiteDatabase checkDB = null; try { checkDB = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READONLY); } catch (SQLiteException e) { /** database does't exist yet. */ } catch (Exception e) { } if (checkDB != null) { checkDB.close(); } return checkDB != null ? true : false; } @Oviewride public void onCreate(SQLiteDatabase db) { Log.v("log_tag", "onCreate"); myDataBase = db; // creating a sample table String CREATE_DEVICE_TABLE = "CREATE TABLE " + DEVICE + " (" + KEY_DEVICEID + " TEXT, " + KEY_OPERATOR + " TEXT, " + KEY_DEVICENAME + " TEXT, " + KEY_DEVICETOTALMEMORY + " INTEGER, " + KEY_SCREENWIDTH + " INTEGER, " + KEY_SCREENHEIGHT + " INTEGER, " + KEY_OPERATINGSYSTEM + " TEXT)"; db.execSQL(CREATE_DEVICE_TABLE); // other tables also can be created from here. } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS " + DEVICE); // Create tables again (as per requirement) this.onCreate(db); } public Cursor rawQuery(String qry) { return myDataBase.rawQuery(qry, null); } public long insert(String tableName, ContentValues cv) { return myDataBase.insert(tableName, null, cv); } public void insertWithOnConflict(String tableName, ContentValues cv, int flag) { myDataBase.insertWithOnConflict(tableName, null, cv, flag); } public long update(String tableName, ContentValues cv, String whereClose) { return myDataBase.update(tableName, cv, whereClose, null); } public int deleteData(String table_name, String whereClause) { return (int) myDataBase.delete(table_name, whereClause, null); } } } import java.io.File; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; public class MySQLiteHelper extends SQLiteOpenHelper implements DBConstants { private static MySQLiteHelper mInstance = null; private SQLiteDatabase myDataBase; private static String DB_PATH = ""; public MySQLiteHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); try { if (checkDataBase()) openDataBase(); else myDataBase = this.getReadableDatabase(); } catch (Exception e) { } } public static MySQLiteHelper instance(Context context) { File outFile = context.getDatabasePath(DATABASE_NAME); DB_PATH = outFile.getPath(); if (mInstance == null) { mInstance = new MySQLiteHelper(context); } return mInstance; } private void openDataBase() throws Exception { try { myDataBase = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READWRITE); } catch (SQLException e) { // TODO: handle exception } } private boolean checkDataBase() { SQLiteDatabase checkDB = null; try { checkDB = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READONLY); } catch (SQLiteException e) { /** database does't exist yet. */ } catch (Exception e) { } if (checkDB != null) { checkDB.close(); } return checkDB != null ? true : false; } @Oviewride public void onCreate(SQLiteDatabase db) { Log.v("log_tag", "onCreate"); myDataBase = db; // creating a sample table String CREATE_DEVICE_TABLE = "CREATE TABLE " + DEVICE + " (" + KEY_DEVICEID + " TEXT, " + KEY_OPERATOR + " TEXT, " + KEY_DEVICENAME + " TEXT, " + KEY_DEVICETOTALMEMORY + " INTEGER, " + KEY_SCREENWIDTH + " INTEGER, " + KEY_SCREENHEIGHT + " INTEGER, " + KEY_OPERATINGSYSTEM + " TEXT)"; db.execSQL(CREATE_DEVICE_TABLE); // other tables also can be created from here. } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS " + DEVICE); // Create tables again (as per requirement) this.onCreate(db); } public Cursor rawQuery(String qry) { return myDataBase.rawQuery(qry, null); } public long insert(String tableName, ContentValues cv) { return myDataBase.insert(tableName, null, cv); } public void insertWithOnConflict(String tableName, ContentValues cv, int flag) { myDataBase.insertWithOnConflict(tableName, null, cv, flag); } public long update(String tableName, ContentValues cv, String whereClose) { return myDataBase.update(tableName, cv, whereClose, null); } public int deleteData(String table_name, String whereClause) { return (int) myDataBase.delete(table_name, whereClause, null); } } } import java.io.File; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; public class MySQLiteHelper extends SQLiteOpenHelper implements DBConstants { private static MySQLiteHelper mInstance = null; private SQLiteDatabase myDataBase; private static String DB_PATH = ""; public MySQLiteHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); try { if (checkDataBase()) openDataBase(); else myDataBase = this.getReadableDatabase(); } catch (Exception e) { } } public static MySQLiteHelper instance(Context context) { File outFile = context.getDatabasePath(DATABASE_NAME); DB_PATH = outFile.getPath(); if (mInstance == null) { mInstance = new MySQLiteHelper(context); } return mInstance; } private void openDataBase() throws Exception { try { myDataBase = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READWRITE); } catch (SQLException e) { // TODO: handle exception } } private boolean checkDataBase() { SQLiteDatabase checkDB = null; try { checkDB = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READONLY); } catch (SQLiteException e) { /** database does't exist yet. */ } catch (Exception e) { } if (checkDB != null) { checkDB.close(); } return checkDB != null ? true : false; } @Oviewride public void onCreate(SQLiteDatabase db) { Log.v("log_tag", "onCreate"); myDataBase = db; // creating a sample table String CREATE_DEVICE_TABLE = "CREATE TABLE " + DEVICE + " (" + KEY_DEVICEID + " TEXT, " + KEY_OPERATOR + " TEXT, " + KEY_DEVICENAME + " TEXT, " + KEY_DEVICETOTALMEMORY + " INTEGER, " + KEY_SCREENWIDTH + " INTEGER, " + KEY_SCREENHEIGHT + " INTEGER, " + KEY_OPERATINGSYSTEM + " TEXT)"; db.execSQL(CREATE_DEVICE_TABLE); // other tables also can be created from here. } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS " + DEVICE); // Create tables again (as per requirement) this.onCreate(db); } public Cursor rawQuery(String qry) { return myDataBase.rawQuery(qry, null); } public long insert(String tableName, ContentValues cv) { return myDataBase.insert(tableName, null, cv); } public void insertWithOnConflict(String tableName, ContentValues cv, int flag) { myDataBase.insertWithOnConflict(tableName, null, cv, flag); } public long update(String tableName, ContentValues cv, String whereClose) { return myDataBase.update(tableName, cv, whereClose, null); } public int deleteData(String table_name, String whereClause) { return (int) myDataBase.delete(table_name, whereClause, null); } } 

    e funcionou paira mim

    Obrigado!

    Eu findi uma solução paira isso, usei abaixo da function:

     public void createDb() { boolean dbExist = checkDataBase(); if (dbExist) { // do nothing - database already exist } else { // call close() for properly copy database file this.getReadableDatabase().close(); try { copyDataBase(); } catch (IOException e) { e.printStackTrace(); throw new Error("Error copying database"); } } } } public void createDb() { boolean dbExist = checkDataBase(); if (dbExist) { // do nothing - database already exist } else { // call close() for properly copy database file this.getReadableDatabase().close(); try { copyDataBase(); } catch (IOException e) { e.printStackTrace(); throw new Error("Error copying database"); } } } } public void createDb() { boolean dbExist = checkDataBase(); if (dbExist) { // do nothing - database already exist } else { // call close() for properly copy database file this.getReadableDatabase().close(); try { copyDataBase(); } catch (IOException e) { e.printStackTrace(); throw new Error("Error copying database"); } } } 

    De acordo com esta publicação , precisamos chamair close() e você pode empurrair o database paira os dois dispositivos também.

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.