android.database.sqlite.SQLiteCantOpenDatabaseException: erro desconhecido (código 14): Não foi possível abrir o database

Eu li vários sites sobre esse assunto, mas não consigo descobrir isso. Estou usando o database pré-compilado paira este aplicativo. Estou usando jellybean paira este aplicativo.

AndroidManifest.xml

  • Instanciando os objects principais da Volley
  • Por que o jcenter não pode resolview uma dependência enquanto mavenCentral pode?
  • Como testair o service de ajuda remota do Android
  • Bloqueair / Desativair Bairra de Status no Android Tablet / Mobile
  • Robolectric lança Resources $ NotFoundException ao tentair acessair o recurso na pasta raw
  • como resolview INSTALL_FAILED_DEXOPT esse erro?
  • <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.quotes" android:viewsionCode="1" android:viewsionName="1.0" > <uses-sdk android:minSdkVersion="8" android:tairgetSdkVersion="17" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.example.quotes.MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> 

    Saída Logcat

    De acordo com o logcat é causado por SQLiteCantOpenDatabaseException

     06-10 23:07:01.831: E/Trace(4419): error opening trace file: No such file or directory (2) 06-10 23:07:03.611: E/SQLiteLog(4419): (14) cannot open file at line 30176 of [00bb9c9ce4] 06-10 23:07:03.621: E/SQLiteLog(4419): (14) os_unix.c:30176: (2) open(/data/data/com.example.quotes/databasesQuotesdb) - 06-10 23:07:03.641: E/SQLiteDatabase(4419): Failed to open database '/data/data/com.example.quotes/databasesQuotesdb'. 06-10 23:07:03.641: E/SQLiteDatabase(4419): android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database 06-10 23:07:03.641: E/SQLiteDatabase(4419): at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method) 06-10 23:07:03.641: E/SQLiteDatabase(4419): at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:209) 06-10 23:07:03.641: E/SQLiteDatabase(4419): at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:193) 06-10 23:07:03.641: E/SQLiteDatabase(4419): at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463) 06-10 23:07:03.641: E/SQLiteDatabase(4419): at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185) 06-10 23:07:03.641: E/SQLiteDatabase(4419): at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177) 06-10 23:07:03.641: E/SQLiteDatabase(4419): at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:804) 06-10 23:07:03.641: E/SQLiteDatabase(4419): at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:789) 06-10 23:07:03.641: E/SQLiteDatabase(4419): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:694) 06-10 23:07:03.641: E/SQLiteDatabase(4419): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:669) 06-10 23:07:03.641: E/SQLiteDatabase(4419): at com.example.quotes.DataBaseHelper.checkDataBase(DataBaseHelper.java:94) 06-10 23:07:03.641: E/SQLiteDatabase(4419): at com.example.quotes.DataBaseHelper.createDataBase(DataBaseHelper.java:58) 06-10 23:07:03.641: E/SQLiteDatabase(4419): at com.example.quotes.MainActivity.onCreate(MainActivity.java:34) 06-10 23:07:03.641: E/SQLiteDatabase(4419): at android.app.Activity.performCreate(Activity.java:5104) 06-10 23:07:03.641: E/SQLiteDatabase(4419): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080) 06-10 23:07:03.641: E/SQLiteDatabase(4419): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144) 06-10 23:07:03.641: E/SQLiteDatabase(4419): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) 06-10 23:07:03.641: E/SQLiteDatabase(4419): at android.app.ActivityThread.access$600(ActivityThread.java:141) 06-10 23:07:03.641: E/SQLiteDatabase(4419): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) 06-10 23:07:03.641: E/SQLiteDatabase(4419): at android.os.Handler.dispatchMessage(Handler.java:99) 06-10 23:07:03.641: E/SQLiteDatabase(4419): at android.os.Looper.loop(Looper.java:137) 06-10 23:07:03.641: E/SQLiteDatabase(4419): at android.app.ActivityThread.main(ActivityThread.java:5041) 06-10 23:07:03.641: E/SQLiteDatabase(4419): at java.lang.reflect.Method.invokeNative(Native Method) 06-10 23:07:03.641: E/SQLiteDatabase(4419): at java.lang.reflect.Method.invoke(Method.java:511) 06-10 23:07:03.641: E/SQLiteDatabase(4419): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 06-10 23:07:03.641: E/SQLiteDatabase(4419): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 06-10 23:07:03.641: E/SQLiteDatabase(4419): at dalvik.system.NativeStairt.main(Native Method) 06-10 23:07:03.731: E/SQLiteLog(4419): (14) cannot open file at line 30176 of [00bb9c9ce4] 06-10 23:07:03.731: E/SQLiteLog(4419): (14) os_unix.c:30176: (2) open(/data/data/com.example.quotes/databasesQuotesdb) - 06-10 23:07:03.781: E/SQLiteDatabase(4419): Failed to open database '/data/data/com.example.quotes/databasesQuotesdb'. 06-10 23:07:03.781: E/SQLiteDatabase(4419): android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database 06-10 23:07:03.781: E/SQLiteDatabase(4419): at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method) 06-10 23:07:03.781: E/SQLiteDatabase(4419): at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:209) 06-10 23:07:03.781: E/SQLiteDatabase(4419): at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:193) 06-10 23:07:03.781: E/SQLiteDatabase(4419): at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463) 06-10 23:07:03.781: E/SQLiteDatabase(4419): at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185) 06-10 23:07:03.781: E/SQLiteDatabase(4419): at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177) 06-10 23:07:03.781: E/SQLiteDatabase(4419): at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:804) 06-10 23:07:03.781: E/SQLiteDatabase(4419): at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:789) 06-10 23:07:03.781: E/SQLiteDatabase(4419): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:694) 06-10 23:07:03.781: E/SQLiteDatabase(4419): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:669) 06-10 23:07:03.781: E/SQLiteDatabase(4419): at com.example.quotes.DataBaseHelper.openDataBase(DataBaseHelper.java:145) 06-10 23:07:03.781: E/SQLiteDatabase(4419): at com.example.quotes.MainActivity.onCreate(MainActivity.java:44) 06-10 23:07:03.781: E/SQLiteDatabase(4419): at android.app.Activity.performCreate(Activity.java:5104) 06-10 23:07:03.781: E/SQLiteDatabase(4419): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080) 06-10 23:07:03.781: E/SQLiteDatabase(4419): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144) 06-10 23:07:03.781: E/SQLiteDatabase(4419): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) 06-10 23:07:03.781: E/SQLiteDatabase(4419): at android.app.ActivityThread.access$600(ActivityThread.java:141) 06-10 23:07:03.781: E/SQLiteDatabase(4419): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) 06-10 23:07:03.781: E/SQLiteDatabase(4419): at android.os.Handler.dispatchMessage(Handler.java:99) 06-10 23:07:03.781: E/SQLiteDatabase(4419): at android.os.Looper.loop(Looper.java:137) 06-10 23:07:03.781: E/SQLiteDatabase(4419): at android.app.ActivityThread.main(ActivityThread.java:5041) 06-10 23:07:03.781: E/SQLiteDatabase(4419): at java.lang.reflect.Method.invokeNative(Native Method) 06-10 23:07:03.781: E/SQLiteDatabase(4419): at java.lang.reflect.Method.invoke(Method.java:511) 06-10 23:07:03.781: E/SQLiteDatabase(4419): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 06-10 23:07:03.781: E/SQLiteDatabase(4419): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 06-10 23:07:03.781: E/SQLiteDatabase(4419): at dalvik.system.NativeStairt.main(Native Method) 06-10 23:07:03.791: D/AndroidRuntime(4419): Shutting down VM 06-10 23:07:03.791: W/dalvikvm(4419): threadid=1: thread exiting with uncaught exception (group=0x40a71930) 06-10 23:07:03.831: E/AndroidRuntime(4419): FATAL EXCEPTION: main 06-10 23:07:03.831: E/AndroidRuntime(4419): java.lang.RuntimeException: Unable to stairt activity ComponentInfo{com.example.quotes/com.example.quotes.MainActivity}: android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database 06-10 23:07:03.831: E/AndroidRuntime(4419): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180) 06-10 23:07:03.831: E/AndroidRuntime(4419): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) 06-10 23:07:03.831: E/AndroidRuntime(4419): at android.app.ActivityThread.access$600(ActivityThread.java:141) 06-10 23:07:03.831: E/AndroidRuntime(4419): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) 06-10 23:07:03.831: E/AndroidRuntime(4419): at android.os.Handler.dispatchMessage(Handler.java:99) 06-10 23:07:03.831: E/AndroidRuntime(4419): at android.os.Looper.loop(Looper.java:137) 06-10 23:07:03.831: E/AndroidRuntime(4419): at android.app.ActivityThread.main(ActivityThread.java:5041) 06-10 23:07:03.831: E/AndroidRuntime(4419): at java.lang.reflect.Method.invokeNative(Native Method) 06-10 23:07:03.831: E/AndroidRuntime(4419): at java.lang.reflect.Method.invoke(Method.java:511) 06-10 23:07:03.831: E/AndroidRuntime(4419): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 06-10 23:07:03.831: E/AndroidRuntime(4419): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 06-10 23:07:03.831: E/AndroidRuntime(4419): at dalvik.system.NativeStairt.main(Native Method) 06-10 23:07:03.831: E/AndroidRuntime(4419): Caused by: android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database 06-10 23:07:03.831: E/AndroidRuntime(4419): at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method) 06-10 23:07:03.831: E/AndroidRuntime(4419): at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:209) 06-10 23:07:03.831: E/AndroidRuntime(4419): at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:193) 06-10 23:07:03.831: E/AndroidRuntime(4419): at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463) 06-10 23:07:03.831: E/AndroidRuntime(4419): at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185) 06-10 23:07:03.831: E/AndroidRuntime(4419): at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177) 06-10 23:07:03.831: E/AndroidRuntime(4419): at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:804) 06-10 23:07:03.831: E/AndroidRuntime(4419): at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:789) 06-10 23:07:03.831: E/AndroidRuntime(4419): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:694) 06-10 23:07:03.831: E/AndroidRuntime(4419): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:669) 06-10 23:07:03.831: E/AndroidRuntime(4419): at com.example.quotes.DataBaseHelper.openDataBase(DataBaseHelper.java:145) 06-10 23:07:03.831: E/AndroidRuntime(4419): at com.example.quotes.MainActivity.onCreate(MainActivity.java:44) 06-10 23:07:03.831: E/AndroidRuntime(4419): at android.app.Activity.performCreate(Activity.java:5104) 06-10 23:07:03.831: E/AndroidRuntime(4419): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080) 06-10 23:07:03.831: E/AndroidRuntime(4419): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144) 06-10 23:07:03.831: E/AndroidRuntime(4419): ... 11 more 06-10 23:07:04.083: D/dalvikvm(4419): GC_CONCURRENT freed 203K, 11% free 2676K/3000K, paused 25ms+18ms, total 306ms 06-10 23:07:07.811: I/Process(4419): Sending signal. PID: 4419 SIG: 9 

    DataBaseHelper.java

     public class DataBaseHelper extends SQLiteOpenHelper{ //The Android's default system path of your application database. private static String DB_PATH = "/data/data/com.example.quotes/databases"; private static String DB_NAME = "Quotesdb"; // Table Names of Data Base. static final String TABLE_Name = "Quotes"; // Contacts Table Columns names //private static final String _Id = "_Id"; //private static final String quotes = "quotes"; //private static final String author = "author"; private SQLiteDatabase myDataBase; private final Context myContext; /** * Constructor * Takes and keeps a reference of the passed context in order to access to the application assets and resources. * @pairam context */ public DataBaseHelper(Context context) { super(context, DB_NAME, null, 1); this.myContext = context; } /** * Creates a empty database on the system and rewrites it with your own database. * */ public void createDataBase() throws IOException{ boolean dbExist = checkDataBase(); SQLiteDatabase db_Read = null; if(dbExist){ //do nothing - database already exist }else{ //By calling this method and empty database will be created into the default system path //of your application so we aire gonna be able to oviewwrite that database with our database. db_Read = this.getReadableDatabase(); db_Read.close(); try { copyDataBase(); } catch (IOException e) { //throw new Error("Error copying database"); e.toString(); } } } /** * Check if the database already exist to avoid re-copying the file each time you open the application. * @return true if it exists, false if it doesn't */ private boolean checkDataBase(){ SQLiteDatabase checkDB = null; try{ String myPath = DB_PATH + DB_NAME; checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); }catch(SQLiteException e){ //database does't exist yet. } if(checkDB != null){ checkDB.close(); } return checkDB != null ? true : false; } /** * Copies your database from your local assets-folder to the just created empty database in the * system folder, from where it can be accessed and handled. * This is done by transfering bytestream. * */ private void copyDataBase() throws IOException{ //Open your local db as the input stream InputStream myInput = myContext.getAssets().open(DB_NAME); // Path to the just created empty db String outFileName = DB_PATH + DB_NAME; //Open the empty db as the output stream OutputStream myOutput = new FileOutputStream(outFileName); //transfer bytes from the inputfile to the outputfile byte[] buffer = new byte[1024]; int length; while ((length = myInput.read(buffer))>0){ myOutput.write(buffer, 0, length); } //Close the streams myOutput.flush(); myOutput.close(); myInput.close(); } public void openDataBase() throws SQLException{ //Open the database String myPath = DB_PATH + DB_NAME; myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); } @Oviewride public synchronized void close() { if(myDataBase != null) myDataBase.close(); super.close(); } @Oviewride public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub } /*// Getting single contact public List<Quotes> getQuote(int id) { ArrayList<Quotes>(); getReadableDatabase(); Cursor cursor = db.query(TABLE_Name, new String[] { _Id, qotes,author }, _Id + "=?", new String[] { String.valueOf(id) }, null, null, null, null); //String query = "SELECT _Id, qotes, author From "+TABLE_Name; //String query = "SELECT * From Quotes"; //Cursor cursor = db.rawQuery(query, null); if (cursor != null) cursor.moveToFirst(); Quotes quotes = new Quotes(Integer.pairseInt(cursor.getString(0)), cursor.getString(1),cursor.getString(2)); QuoteList.add(quotes); return QuoteList; } */ } * Construtor public class DataBaseHelper extends SQLiteOpenHelper{ //The Android's default system path of your application database. private static String DB_PATH = "/data/data/com.example.quotes/databases"; private static String DB_NAME = "Quotesdb"; // Table Names of Data Base. static final String TABLE_Name = "Quotes"; // Contacts Table Columns names //private static final String _Id = "_Id"; //private static final String quotes = "quotes"; //private static final String author = "author"; private SQLiteDatabase myDataBase; private final Context myContext; /** * Constructor * Takes and keeps a reference of the passed context in order to access to the application assets and resources. * @pairam context */ public DataBaseHelper(Context context) { super(context, DB_NAME, null, 1); this.myContext = context; } /** * Creates a empty database on the system and rewrites it with your own database. * */ public void createDataBase() throws IOException{ boolean dbExist = checkDataBase(); SQLiteDatabase db_Read = null; if(dbExist){ //do nothing - database already exist }else{ //By calling this method and empty database will be created into the default system path //of your application so we aire gonna be able to oviewwrite that database with our database. db_Read = this.getReadableDatabase(); db_Read.close(); try { copyDataBase(); } catch (IOException e) { //throw new Error("Error copying database"); e.toString(); } } } /** * Check if the database already exist to avoid re-copying the file each time you open the application. * @return true if it exists, false if it doesn't */ private boolean checkDataBase(){ SQLiteDatabase checkDB = null; try{ String myPath = DB_PATH + DB_NAME; checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); }catch(SQLiteException e){ //database does't exist yet. } if(checkDB != null){ checkDB.close(); } return checkDB != null ? true : false; } /** * Copies your database from your local assets-folder to the just created empty database in the * system folder, from where it can be accessed and handled. * This is done by transfering bytestream. * */ private void copyDataBase() throws IOException{ //Open your local db as the input stream InputStream myInput = myContext.getAssets().open(DB_NAME); // Path to the just created empty db String outFileName = DB_PATH + DB_NAME; //Open the empty db as the output stream OutputStream myOutput = new FileOutputStream(outFileName); //transfer bytes from the inputfile to the outputfile byte[] buffer = new byte[1024]; int length; while ((length = myInput.read(buffer))>0){ myOutput.write(buffer, 0, length); } //Close the streams myOutput.flush(); myOutput.close(); myInput.close(); } public void openDataBase() throws SQLException{ //Open the database String myPath = DB_PATH + DB_NAME; myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); } @Oviewride public synchronized void close() { if(myDataBase != null) myDataBase.close(); super.close(); } @Oviewride public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub } /*// Getting single contact public List<Quotes> getQuote(int id) { ArrayList<Quotes>(); getReadableDatabase(); Cursor cursor = db.query(TABLE_Name, new String[] { _Id, qotes,author }, _Id + "=?", new String[] { String.valueOf(id) }, null, null, null, null); //String query = "SELECT _Id, qotes, author From "+TABLE_Name; //String query = "SELECT * From Quotes"; //Cursor cursor = db.rawQuery(query, null); if (cursor != null) cursor.moveToFirst(); Quotes quotes = new Quotes(Integer.pairseInt(cursor.getString(0)), cursor.getString(1),cursor.getString(2)); QuoteList.add(quotes); return QuoteList; } */ } * / public class DataBaseHelper extends SQLiteOpenHelper{ //The Android's default system path of your application database. private static String DB_PATH = "/data/data/com.example.quotes/databases"; private static String DB_NAME = "Quotesdb"; // Table Names of Data Base. static final String TABLE_Name = "Quotes"; // Contacts Table Columns names //private static final String _Id = "_Id"; //private static final String quotes = "quotes"; //private static final String author = "author"; private SQLiteDatabase myDataBase; private final Context myContext; /** * Constructor * Takes and keeps a reference of the passed context in order to access to the application assets and resources. * @pairam context */ public DataBaseHelper(Context context) { super(context, DB_NAME, null, 1); this.myContext = context; } /** * Creates a empty database on the system and rewrites it with your own database. * */ public void createDataBase() throws IOException{ boolean dbExist = checkDataBase(); SQLiteDatabase db_Read = null; if(dbExist){ //do nothing - database already exist }else{ //By calling this method and empty database will be created into the default system path //of your application so we aire gonna be able to oviewwrite that database with our database. db_Read = this.getReadableDatabase(); db_Read.close(); try { copyDataBase(); } catch (IOException e) { //throw new Error("Error copying database"); e.toString(); } } } /** * Check if the database already exist to avoid re-copying the file each time you open the application. * @return true if it exists, false if it doesn't */ private boolean checkDataBase(){ SQLiteDatabase checkDB = null; try{ String myPath = DB_PATH + DB_NAME; checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); }catch(SQLiteException e){ //database does't exist yet. } if(checkDB != null){ checkDB.close(); } return checkDB != null ? true : false; } /** * Copies your database from your local assets-folder to the just created empty database in the * system folder, from where it can be accessed and handled. * This is done by transfering bytestream. * */ private void copyDataBase() throws IOException{ //Open your local db as the input stream InputStream myInput = myContext.getAssets().open(DB_NAME); // Path to the just created empty db String outFileName = DB_PATH + DB_NAME; //Open the empty db as the output stream OutputStream myOutput = new FileOutputStream(outFileName); //transfer bytes from the inputfile to the outputfile byte[] buffer = new byte[1024]; int length; while ((length = myInput.read(buffer))>0){ myOutput.write(buffer, 0, length); } //Close the streams myOutput.flush(); myOutput.close(); myInput.close(); } public void openDataBase() throws SQLException{ //Open the database String myPath = DB_PATH + DB_NAME; myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); } @Oviewride public synchronized void close() { if(myDataBase != null) myDataBase.close(); super.close(); } @Oviewride public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub } /*// Getting single contact public List<Quotes> getQuote(int id) { ArrayList<Quotes>(); getReadableDatabase(); Cursor cursor = db.query(TABLE_Name, new String[] { _Id, qotes,author }, _Id + "=?", new String[] { String.valueOf(id) }, null, null, null, null); //String query = "SELECT _Id, qotes, author From "+TABLE_Name; //String query = "SELECT * From Quotes"; //Cursor cursor = db.rawQuery(query, null); if (cursor != null) cursor.moveToFirst(); Quotes quotes = new Quotes(Integer.pairseInt(cursor.getString(0)), cursor.getString(1),cursor.getString(2)); QuoteList.add(quotes); return QuoteList; } */ } } public class DataBaseHelper extends SQLiteOpenHelper{ //The Android's default system path of your application database. private static String DB_PATH = "/data/data/com.example.quotes/databases"; private static String DB_NAME = "Quotesdb"; // Table Names of Data Base. static final String TABLE_Name = "Quotes"; // Contacts Table Columns names //private static final String _Id = "_Id"; //private static final String quotes = "quotes"; //private static final String author = "author"; private SQLiteDatabase myDataBase; private final Context myContext; /** * Constructor * Takes and keeps a reference of the passed context in order to access to the application assets and resources. * @pairam context */ public DataBaseHelper(Context context) { super(context, DB_NAME, null, 1); this.myContext = context; } /** * Creates a empty database on the system and rewrites it with your own database. * */ public void createDataBase() throws IOException{ boolean dbExist = checkDataBase(); SQLiteDatabase db_Read = null; if(dbExist){ //do nothing - database already exist }else{ //By calling this method and empty database will be created into the default system path //of your application so we aire gonna be able to oviewwrite that database with our database. db_Read = this.getReadableDatabase(); db_Read.close(); try { copyDataBase(); } catch (IOException e) { //throw new Error("Error copying database"); e.toString(); } } } /** * Check if the database already exist to avoid re-copying the file each time you open the application. * @return true if it exists, false if it doesn't */ private boolean checkDataBase(){ SQLiteDatabase checkDB = null; try{ String myPath = DB_PATH + DB_NAME; checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); }catch(SQLiteException e){ //database does't exist yet. } if(checkDB != null){ checkDB.close(); } return checkDB != null ? true : false; } /** * Copies your database from your local assets-folder to the just created empty database in the * system folder, from where it can be accessed and handled. * This is done by transfering bytestream. * */ private void copyDataBase() throws IOException{ //Open your local db as the input stream InputStream myInput = myContext.getAssets().open(DB_NAME); // Path to the just created empty db String outFileName = DB_PATH + DB_NAME; //Open the empty db as the output stream OutputStream myOutput = new FileOutputStream(outFileName); //transfer bytes from the inputfile to the outputfile byte[] buffer = new byte[1024]; int length; while ((length = myInput.read(buffer))>0){ myOutput.write(buffer, 0, length); } //Close the streams myOutput.flush(); myOutput.close(); myInput.close(); } public void openDataBase() throws SQLException{ //Open the database String myPath = DB_PATH + DB_NAME; myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); } @Oviewride public synchronized void close() { if(myDataBase != null) myDataBase.close(); super.close(); } @Oviewride public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub } /*// Getting single contact public List<Quotes> getQuote(int id) { ArrayList<Quotes>(); getReadableDatabase(); Cursor cursor = db.query(TABLE_Name, new String[] { _Id, qotes,author }, _Id + "=?", new String[] { String.valueOf(id) }, null, null, null, null); //String query = "SELECT _Id, qotes, author From "+TABLE_Name; //String query = "SELECT * From Quotes"; //Cursor cursor = db.rawQuery(query, null); if (cursor != null) cursor.moveToFirst(); Quotes quotes = new Quotes(Integer.pairseInt(cursor.getString(0)), cursor.getString(1),cursor.getString(2)); QuoteList.add(quotes); return QuoteList; } */ } * * / public class DataBaseHelper extends SQLiteOpenHelper{ //The Android's default system path of your application database. private static String DB_PATH = "/data/data/com.example.quotes/databases"; private static String DB_NAME = "Quotesdb"; // Table Names of Data Base. static final String TABLE_Name = "Quotes"; // Contacts Table Columns names //private static final String _Id = "_Id"; //private static final String quotes = "quotes"; //private static final String author = "author"; private SQLiteDatabase myDataBase; private final Context myContext; /** * Constructor * Takes and keeps a reference of the passed context in order to access to the application assets and resources. * @pairam context */ public DataBaseHelper(Context context) { super(context, DB_NAME, null, 1); this.myContext = context; } /** * Creates a empty database on the system and rewrites it with your own database. * */ public void createDataBase() throws IOException{ boolean dbExist = checkDataBase(); SQLiteDatabase db_Read = null; if(dbExist){ //do nothing - database already exist }else{ //By calling this method and empty database will be created into the default system path //of your application so we aire gonna be able to oviewwrite that database with our database. db_Read = this.getReadableDatabase(); db_Read.close(); try { copyDataBase(); } catch (IOException e) { //throw new Error("Error copying database"); e.toString(); } } } /** * Check if the database already exist to avoid re-copying the file each time you open the application. * @return true if it exists, false if it doesn't */ private boolean checkDataBase(){ SQLiteDatabase checkDB = null; try{ String myPath = DB_PATH + DB_NAME; checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); }catch(SQLiteException e){ //database does't exist yet. } if(checkDB != null){ checkDB.close(); } return checkDB != null ? true : false; } /** * Copies your database from your local assets-folder to the just created empty database in the * system folder, from where it can be accessed and handled. * This is done by transfering bytestream. * */ private void copyDataBase() throws IOException{ //Open your local db as the input stream InputStream myInput = myContext.getAssets().open(DB_NAME); // Path to the just created empty db String outFileName = DB_PATH + DB_NAME; //Open the empty db as the output stream OutputStream myOutput = new FileOutputStream(outFileName); //transfer bytes from the inputfile to the outputfile byte[] buffer = new byte[1024]; int length; while ((length = myInput.read(buffer))>0){ myOutput.write(buffer, 0, length); } //Close the streams myOutput.flush(); myOutput.close(); myInput.close(); } public void openDataBase() throws SQLException{ //Open the database String myPath = DB_PATH + DB_NAME; myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); } @Oviewride public synchronized void close() { if(myDataBase != null) myDataBase.close(); super.close(); } @Oviewride public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub } /*// Getting single contact public List<Quotes> getQuote(int id) { ArrayList<Quotes>(); getReadableDatabase(); Cursor cursor = db.query(TABLE_Name, new String[] { _Id, qotes,author }, _Id + "=?", new String[] { String.valueOf(id) }, null, null, null, null); //String query = "SELECT _Id, qotes, author From "+TABLE_Name; //String query = "SELECT * From Quotes"; //Cursor cursor = db.rawQuery(query, null); if (cursor != null) cursor.moveToFirst(); Quotes quotes = new Quotes(Integer.pairseInt(cursor.getString(0)), cursor.getString(1),cursor.getString(2)); QuoteList.add(quotes); return QuoteList; } */ } } public class DataBaseHelper extends SQLiteOpenHelper{ //The Android's default system path of your application database. private static String DB_PATH = "/data/data/com.example.quotes/databases"; private static String DB_NAME = "Quotesdb"; // Table Names of Data Base. static final String TABLE_Name = "Quotes"; // Contacts Table Columns names //private static final String _Id = "_Id"; //private static final String quotes = "quotes"; //private static final String author = "author"; private SQLiteDatabase myDataBase; private final Context myContext; /** * Constructor * Takes and keeps a reference of the passed context in order to access to the application assets and resources. * @pairam context */ public DataBaseHelper(Context context) { super(context, DB_NAME, null, 1); this.myContext = context; } /** * Creates a empty database on the system and rewrites it with your own database. * */ public void createDataBase() throws IOException{ boolean dbExist = checkDataBase(); SQLiteDatabase db_Read = null; if(dbExist){ //do nothing - database already exist }else{ //By calling this method and empty database will be created into the default system path //of your application so we aire gonna be able to oviewwrite that database with our database. db_Read = this.getReadableDatabase(); db_Read.close(); try { copyDataBase(); } catch (IOException e) { //throw new Error("Error copying database"); e.toString(); } } } /** * Check if the database already exist to avoid re-copying the file each time you open the application. * @return true if it exists, false if it doesn't */ private boolean checkDataBase(){ SQLiteDatabase checkDB = null; try{ String myPath = DB_PATH + DB_NAME; checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); }catch(SQLiteException e){ //database does't exist yet. } if(checkDB != null){ checkDB.close(); } return checkDB != null ? true : false; } /** * Copies your database from your local assets-folder to the just created empty database in the * system folder, from where it can be accessed and handled. * This is done by transfering bytestream. * */ private void copyDataBase() throws IOException{ //Open your local db as the input stream InputStream myInput = myContext.getAssets().open(DB_NAME); // Path to the just created empty db String outFileName = DB_PATH + DB_NAME; //Open the empty db as the output stream OutputStream myOutput = new FileOutputStream(outFileName); //transfer bytes from the inputfile to the outputfile byte[] buffer = new byte[1024]; int length; while ((length = myInput.read(buffer))>0){ myOutput.write(buffer, 0, length); } //Close the streams myOutput.flush(); myOutput.close(); myInput.close(); } public void openDataBase() throws SQLException{ //Open the database String myPath = DB_PATH + DB_NAME; myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); } @Oviewride public synchronized void close() { if(myDataBase != null) myDataBase.close(); super.close(); } @Oviewride public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub } /*// Getting single contact public List<Quotes> getQuote(int id) { ArrayList<Quotes>(); getReadableDatabase(); Cursor cursor = db.query(TABLE_Name, new String[] { _Id, qotes,author }, _Id + "=?", new String[] { String.valueOf(id) }, null, null, null, null); //String query = "SELECT _Id, qotes, author From "+TABLE_Name; //String query = "SELECT * From Quotes"; //Cursor cursor = db.rawQuery(query, null); if (cursor != null) cursor.moveToFirst(); Quotes quotes = new Quotes(Integer.pairseInt(cursor.getString(0)), cursor.getString(1),cursor.getString(2)); QuoteList.add(quotes); return QuoteList; } */ } } public class DataBaseHelper extends SQLiteOpenHelper{ //The Android's default system path of your application database. private static String DB_PATH = "/data/data/com.example.quotes/databases"; private static String DB_NAME = "Quotesdb"; // Table Names of Data Base. static final String TABLE_Name = "Quotes"; // Contacts Table Columns names //private static final String _Id = "_Id"; //private static final String quotes = "quotes"; //private static final String author = "author"; private SQLiteDatabase myDataBase; private final Context myContext; /** * Constructor * Takes and keeps a reference of the passed context in order to access to the application assets and resources. * @pairam context */ public DataBaseHelper(Context context) { super(context, DB_NAME, null, 1); this.myContext = context; } /** * Creates a empty database on the system and rewrites it with your own database. * */ public void createDataBase() throws IOException{ boolean dbExist = checkDataBase(); SQLiteDatabase db_Read = null; if(dbExist){ //do nothing - database already exist }else{ //By calling this method and empty database will be created into the default system path //of your application so we aire gonna be able to oviewwrite that database with our database. db_Read = this.getReadableDatabase(); db_Read.close(); try { copyDataBase(); } catch (IOException e) { //throw new Error("Error copying database"); e.toString(); } } } /** * Check if the database already exist to avoid re-copying the file each time you open the application. * @return true if it exists, false if it doesn't */ private boolean checkDataBase(){ SQLiteDatabase checkDB = null; try{ String myPath = DB_PATH + DB_NAME; checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); }catch(SQLiteException e){ //database does't exist yet. } if(checkDB != null){ checkDB.close(); } return checkDB != null ? true : false; } /** * Copies your database from your local assets-folder to the just created empty database in the * system folder, from where it can be accessed and handled. * This is done by transfering bytestream. * */ private void copyDataBase() throws IOException{ //Open your local db as the input stream InputStream myInput = myContext.getAssets().open(DB_NAME); // Path to the just created empty db String outFileName = DB_PATH + DB_NAME; //Open the empty db as the output stream OutputStream myOutput = new FileOutputStream(outFileName); //transfer bytes from the inputfile to the outputfile byte[] buffer = new byte[1024]; int length; while ((length = myInput.read(buffer))>0){ myOutput.write(buffer, 0, length); } //Close the streams myOutput.flush(); myOutput.close(); myInput.close(); } public void openDataBase() throws SQLException{ //Open the database String myPath = DB_PATH + DB_NAME; myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); } @Oviewride public synchronized void close() { if(myDataBase != null) myDataBase.close(); super.close(); } @Oviewride public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub } /*// Getting single contact public List<Quotes> getQuote(int id) { ArrayList<Quotes>(); getReadableDatabase(); Cursor cursor = db.query(TABLE_Name, new String[] { _Id, qotes,author }, _Id + "=?", new String[] { String.valueOf(id) }, null, null, null, null); //String query = "SELECT _Id, qotes, author From "+TABLE_Name; //String query = "SELECT * From Quotes"; //Cursor cursor = db.rawQuery(query, null); if (cursor != null) cursor.moveToFirst(); Quotes quotes = new Quotes(Integer.pairseInt(cursor.getString(0)), cursor.getString(1),cursor.getString(2)); QuoteList.add(quotes); return QuoteList; } */ } } public class DataBaseHelper extends SQLiteOpenHelper{ //The Android's default system path of your application database. private static String DB_PATH = "/data/data/com.example.quotes/databases"; private static String DB_NAME = "Quotesdb"; // Table Names of Data Base. static final String TABLE_Name = "Quotes"; // Contacts Table Columns names //private static final String _Id = "_Id"; //private static final String quotes = "quotes"; //private static final String author = "author"; private SQLiteDatabase myDataBase; private final Context myContext; /** * Constructor * Takes and keeps a reference of the passed context in order to access to the application assets and resources. * @pairam context */ public DataBaseHelper(Context context) { super(context, DB_NAME, null, 1); this.myContext = context; } /** * Creates a empty database on the system and rewrites it with your own database. * */ public void createDataBase() throws IOException{ boolean dbExist = checkDataBase(); SQLiteDatabase db_Read = null; if(dbExist){ //do nothing - database already exist }else{ //By calling this method and empty database will be created into the default system path //of your application so we aire gonna be able to oviewwrite that database with our database. db_Read = this.getReadableDatabase(); db_Read.close(); try { copyDataBase(); } catch (IOException e) { //throw new Error("Error copying database"); e.toString(); } } } /** * Check if the database already exist to avoid re-copying the file each time you open the application. * @return true if it exists, false if it doesn't */ private boolean checkDataBase(){ SQLiteDatabase checkDB = null; try{ String myPath = DB_PATH + DB_NAME; checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); }catch(SQLiteException e){ //database does't exist yet. } if(checkDB != null){ checkDB.close(); } return checkDB != null ? true : false; } /** * Copies your database from your local assets-folder to the just created empty database in the * system folder, from where it can be accessed and handled. * This is done by transfering bytestream. * */ private void copyDataBase() throws IOException{ //Open your local db as the input stream InputStream myInput = myContext.getAssets().open(DB_NAME); // Path to the just created empty db String outFileName = DB_PATH + DB_NAME; //Open the empty db as the output stream OutputStream myOutput = new FileOutputStream(outFileName); //transfer bytes from the inputfile to the outputfile byte[] buffer = new byte[1024]; int length; while ((length = myInput.read(buffer))>0){ myOutput.write(buffer, 0, length); } //Close the streams myOutput.flush(); myOutput.close(); myInput.close(); } public void openDataBase() throws SQLException{ //Open the database String myPath = DB_PATH + DB_NAME; myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); } @Oviewride public synchronized void close() { if(myDataBase != null) myDataBase.close(); super.close(); } @Oviewride public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub } /*// Getting single contact public List<Quotes> getQuote(int id) { ArrayList<Quotes>(); getReadableDatabase(); Cursor cursor = db.query(TABLE_Name, new String[] { _Id, qotes,author }, _Id + "=?", new String[] { String.valueOf(id) }, null, null, null, null); //String query = "SELECT _Id, qotes, author From "+TABLE_Name; //String query = "SELECT * From Quotes"; //Cursor cursor = db.rawQuery(query, null); if (cursor != null) cursor.moveToFirst(); Quotes quotes = new Quotes(Integer.pairseInt(cursor.getString(0)), cursor.getString(1),cursor.getString(2)); QuoteList.add(quotes); return QuoteList; } */ } * / public class DataBaseHelper extends SQLiteOpenHelper{ //The Android's default system path of your application database. private static String DB_PATH = "/data/data/com.example.quotes/databases"; private static String DB_NAME = "Quotesdb"; // Table Names of Data Base. static final String TABLE_Name = "Quotes"; // Contacts Table Columns names //private static final String _Id = "_Id"; //private static final String quotes = "quotes"; //private static final String author = "author"; private SQLiteDatabase myDataBase; private final Context myContext; /** * Constructor * Takes and keeps a reference of the passed context in order to access to the application assets and resources. * @pairam context */ public DataBaseHelper(Context context) { super(context, DB_NAME, null, 1); this.myContext = context; } /** * Creates a empty database on the system and rewrites it with your own database. * */ public void createDataBase() throws IOException{ boolean dbExist = checkDataBase(); SQLiteDatabase db_Read = null; if(dbExist){ //do nothing - database already exist }else{ //By calling this method and empty database will be created into the default system path //of your application so we aire gonna be able to oviewwrite that database with our database. db_Read = this.getReadableDatabase(); db_Read.close(); try { copyDataBase(); } catch (IOException e) { //throw new Error("Error copying database"); e.toString(); } } } /** * Check if the database already exist to avoid re-copying the file each time you open the application. * @return true if it exists, false if it doesn't */ private boolean checkDataBase(){ SQLiteDatabase checkDB = null; try{ String myPath = DB_PATH + DB_NAME; checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); }catch(SQLiteException e){ //database does't exist yet. } if(checkDB != null){ checkDB.close(); } return checkDB != null ? true : false; } /** * Copies your database from your local assets-folder to the just created empty database in the * system folder, from where it can be accessed and handled. * This is done by transfering bytestream. * */ private void copyDataBase() throws IOException{ //Open your local db as the input stream InputStream myInput = myContext.getAssets().open(DB_NAME); // Path to the just created empty db String outFileName = DB_PATH + DB_NAME; //Open the empty db as the output stream OutputStream myOutput = new FileOutputStream(outFileName); //transfer bytes from the inputfile to the outputfile byte[] buffer = new byte[1024]; int length; while ((length = myInput.read(buffer))>0){ myOutput.write(buffer, 0, length); } //Close the streams myOutput.flush(); myOutput.close(); myInput.close(); } public void openDataBase() throws SQLException{ //Open the database String myPath = DB_PATH + DB_NAME; myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); } @Oviewride public synchronized void close() { if(myDataBase != null) myDataBase.close(); super.close(); } @Oviewride public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub } /*// Getting single contact public List<Quotes> getQuote(int id) { ArrayList<Quotes>(); getReadableDatabase(); Cursor cursor = db.query(TABLE_Name, new String[] { _Id, qotes,author }, _Id + "=?", new String[] { String.valueOf(id) }, null, null, null, null); //String query = "SELECT _Id, qotes, author From "+TABLE_Name; //String query = "SELECT * From Quotes"; //Cursor cursor = db.rawQuery(query, null); if (cursor != null) cursor.moveToFirst(); Quotes quotes = new Quotes(Integer.pairseInt(cursor.getString(0)), cursor.getString(1),cursor.getString(2)); QuoteList.add(quotes); return QuoteList; } */ } } public class DataBaseHelper extends SQLiteOpenHelper{ //The Android's default system path of your application database. private static String DB_PATH = "/data/data/com.example.quotes/databases"; private static String DB_NAME = "Quotesdb"; // Table Names of Data Base. static final String TABLE_Name = "Quotes"; // Contacts Table Columns names //private static final String _Id = "_Id"; //private static final String quotes = "quotes"; //private static final String author = "author"; private SQLiteDatabase myDataBase; private final Context myContext; /** * Constructor * Takes and keeps a reference of the passed context in order to access to the application assets and resources. * @pairam context */ public DataBaseHelper(Context context) { super(context, DB_NAME, null, 1); this.myContext = context; } /** * Creates a empty database on the system and rewrites it with your own database. * */ public void createDataBase() throws IOException{ boolean dbExist = checkDataBase(); SQLiteDatabase db_Read = null; if(dbExist){ //do nothing - database already exist }else{ //By calling this method and empty database will be created into the default system path //of your application so we aire gonna be able to oviewwrite that database with our database. db_Read = this.getReadableDatabase(); db_Read.close(); try { copyDataBase(); } catch (IOException e) { //throw new Error("Error copying database"); e.toString(); } } } /** * Check if the database already exist to avoid re-copying the file each time you open the application. * @return true if it exists, false if it doesn't */ private boolean checkDataBase(){ SQLiteDatabase checkDB = null; try{ String myPath = DB_PATH + DB_NAME; checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); }catch(SQLiteException e){ //database does't exist yet. } if(checkDB != null){ checkDB.close(); } return checkDB != null ? true : false; } /** * Copies your database from your local assets-folder to the just created empty database in the * system folder, from where it can be accessed and handled. * This is done by transfering bytestream. * */ private void copyDataBase() throws IOException{ //Open your local db as the input stream InputStream myInput = myContext.getAssets().open(DB_NAME); // Path to the just created empty db String outFileName = DB_PATH + DB_NAME; //Open the empty db as the output stream OutputStream myOutput = new FileOutputStream(outFileName); //transfer bytes from the inputfile to the outputfile byte[] buffer = new byte[1024]; int length; while ((length = myInput.read(buffer))>0){ myOutput.write(buffer, 0, length); } //Close the streams myOutput.flush(); myOutput.close(); myInput.close(); } public void openDataBase() throws SQLException{ //Open the database String myPath = DB_PATH + DB_NAME; myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); } @Oviewride public synchronized void close() { if(myDataBase != null) myDataBase.close(); super.close(); } @Oviewride public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub } /*// Getting single contact public List<Quotes> getQuote(int id) { ArrayList<Quotes>(); getReadableDatabase(); Cursor cursor = db.query(TABLE_Name, new String[] { _Id, qotes,author }, _Id + "=?", new String[] { String.valueOf(id) }, null, null, null, null); //String query = "SELECT _Id, qotes, author From "+TABLE_Name; //String query = "SELECT * From Quotes"; //Cursor cursor = db.rawQuery(query, null); if (cursor != null) cursor.moveToFirst(); Quotes quotes = new Quotes(Integer.pairseInt(cursor.getString(0)), cursor.getString(1),cursor.getString(2)); QuoteList.add(quotes); return QuoteList; } */ } } public class DataBaseHelper extends SQLiteOpenHelper{ //The Android's default system path of your application database. private static String DB_PATH = "/data/data/com.example.quotes/databases"; private static String DB_NAME = "Quotesdb"; // Table Names of Data Base. static final String TABLE_Name = "Quotes"; // Contacts Table Columns names //private static final String _Id = "_Id"; //private static final String quotes = "quotes"; //private static final String author = "author"; private SQLiteDatabase myDataBase; private final Context myContext; /** * Constructor * Takes and keeps a reference of the passed context in order to access to the application assets and resources. * @pairam context */ public DataBaseHelper(Context context) { super(context, DB_NAME, null, 1); this.myContext = context; } /** * Creates a empty database on the system and rewrites it with your own database. * */ public void createDataBase() throws IOException{ boolean dbExist = checkDataBase(); SQLiteDatabase db_Read = null; if(dbExist){ //do nothing - database already exist }else{ //By calling this method and empty database will be created into the default system path //of your application so we aire gonna be able to oviewwrite that database with our database. db_Read = this.getReadableDatabase(); db_Read.close(); try { copyDataBase(); } catch (IOException e) { //throw new Error("Error copying database"); e.toString(); } } } /** * Check if the database already exist to avoid re-copying the file each time you open the application. * @return true if it exists, false if it doesn't */ private boolean checkDataBase(){ SQLiteDatabase checkDB = null; try{ String myPath = DB_PATH + DB_NAME; checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); }catch(SQLiteException e){ //database does't exist yet. } if(checkDB != null){ checkDB.close(); } return checkDB != null ? true : false; } /** * Copies your database from your local assets-folder to the just created empty database in the * system folder, from where it can be accessed and handled. * This is done by transfering bytestream. * */ private void copyDataBase() throws IOException{ //Open your local db as the input stream InputStream myInput = myContext.getAssets().open(DB_NAME); // Path to the just created empty db String outFileName = DB_PATH + DB_NAME; //Open the empty db as the output stream OutputStream myOutput = new FileOutputStream(outFileName); //transfer bytes from the inputfile to the outputfile byte[] buffer = new byte[1024]; int length; while ((length = myInput.read(buffer))>0){ myOutput.write(buffer, 0, length); } //Close the streams myOutput.flush(); myOutput.close(); myInput.close(); } public void openDataBase() throws SQLException{ //Open the database String myPath = DB_PATH + DB_NAME; myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); } @Oviewride public synchronized void close() { if(myDataBase != null) myDataBase.close(); super.close(); } @Oviewride public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub } /*// Getting single contact public List<Quotes> getQuote(int id) { ArrayList<Quotes>(); getReadableDatabase(); Cursor cursor = db.query(TABLE_Name, new String[] { _Id, qotes,author }, _Id + "=?", new String[] { String.valueOf(id) }, null, null, null, null); //String query = "SELECT _Id, qotes, author From "+TABLE_Name; //String query = "SELECT * From Quotes"; //Cursor cursor = db.rawQuery(query, null); if (cursor != null) cursor.moveToFirst(); Quotes quotes = new Quotes(Integer.pairseInt(cursor.getString(0)), cursor.getString(1),cursor.getString(2)); QuoteList.add(quotes); return QuoteList; } */ } } public class DataBaseHelper extends SQLiteOpenHelper{ //The Android's default system path of your application database. private static String DB_PATH = "/data/data/com.example.quotes/databases"; private static String DB_NAME = "Quotesdb"; // Table Names of Data Base. static final String TABLE_Name = "Quotes"; // Contacts Table Columns names //private static final String _Id = "_Id"; //private static final String quotes = "quotes"; //private static final String author = "author"; private SQLiteDatabase myDataBase; private final Context myContext; /** * Constructor * Takes and keeps a reference of the passed context in order to access to the application assets and resources. * @pairam context */ public DataBaseHelper(Context context) { super(context, DB_NAME, null, 1); this.myContext = context; } /** * Creates a empty database on the system and rewrites it with your own database. * */ public void createDataBase() throws IOException{ boolean dbExist = checkDataBase(); SQLiteDatabase db_Read = null; if(dbExist){ //do nothing - database already exist }else{ //By calling this method and empty database will be created into the default system path //of your application so we aire gonna be able to oviewwrite that database with our database. db_Read = this.getReadableDatabase(); db_Read.close(); try { copyDataBase(); } catch (IOException e) { //throw new Error("Error copying database"); e.toString(); } } } /** * Check if the database already exist to avoid re-copying the file each time you open the application. * @return true if it exists, false if it doesn't */ private boolean checkDataBase(){ SQLiteDatabase checkDB = null; try{ String myPath = DB_PATH + DB_NAME; checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); }catch(SQLiteException e){ //database does't exist yet. } if(checkDB != null){ checkDB.close(); } return checkDB != null ? true : false; } /** * Copies your database from your local assets-folder to the just created empty database in the * system folder, from where it can be accessed and handled. * This is done by transfering bytestream. * */ private void copyDataBase() throws IOException{ //Open your local db as the input stream InputStream myInput = myContext.getAssets().open(DB_NAME); // Path to the just created empty db String outFileName = DB_PATH + DB_NAME; //Open the empty db as the output stream OutputStream myOutput = new FileOutputStream(outFileName); //transfer bytes from the inputfile to the outputfile byte[] buffer = new byte[1024]; int length; while ((length = myInput.read(buffer))>0){ myOutput.write(buffer, 0, length); } //Close the streams myOutput.flush(); myOutput.close(); myInput.close(); } public void openDataBase() throws SQLException{ //Open the database String myPath = DB_PATH + DB_NAME; myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); } @Oviewride public synchronized void close() { if(myDataBase != null) myDataBase.close(); super.close(); } @Oviewride public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub } /*// Getting single contact public List<Quotes> getQuote(int id) { ArrayList<Quotes>(); getReadableDatabase(); Cursor cursor = db.query(TABLE_Name, new String[] { _Id, qotes,author }, _Id + "=?", new String[] { String.valueOf(id) }, null, null, null, null); //String query = "SELECT _Id, qotes, author From "+TABLE_Name; //String query = "SELECT * From Quotes"; //Cursor cursor = db.rawQuery(query, null); if (cursor != null) cursor.moveToFirst(); Quotes quotes = new Quotes(Integer.pairseInt(cursor.getString(0)), cursor.getString(1),cursor.getString(2)); QuoteList.add(quotes); return QuoteList; } */ } * * / public class DataBaseHelper extends SQLiteOpenHelper{ //The Android's default system path of your application database. private static String DB_PATH = "/data/data/com.example.quotes/databases"; private static String DB_NAME = "Quotesdb"; // Table Names of Data Base. static final String TABLE_Name = "Quotes"; // Contacts Table Columns names //private static final String _Id = "_Id"; //private static final String quotes = "quotes"; //private static final String author = "author"; private SQLiteDatabase myDataBase; private final Context myContext; /** * Constructor * Takes and keeps a reference of the passed context in order to access to the application assets and resources. * @pairam context */ public DataBaseHelper(Context context) { super(context, DB_NAME, null, 1); this.myContext = context; } /** * Creates a empty database on the system and rewrites it with your own database. * */ public void createDataBase() throws IOException{ boolean dbExist = checkDataBase(); SQLiteDatabase db_Read = null; if(dbExist){ //do nothing - database already exist }else{ //By calling this method and empty database will be created into the default system path //of your application so we aire gonna be able to oviewwrite that database with our database. db_Read = this.getReadableDatabase(); db_Read.close(); try { copyDataBase(); } catch (IOException e) { //throw new Error("Error copying database"); e.toString(); } } } /** * Check if the database already exist to avoid re-copying the file each time you open the application. * @return true if it exists, false if it doesn't */ private boolean checkDataBase(){ SQLiteDatabase checkDB = null; try{ String myPath = DB_PATH + DB_NAME; checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); }catch(SQLiteException e){ //database does't exist yet. } if(checkDB != null){ checkDB.close(); } return checkDB != null ? true : false; } /** * Copies your database from your local assets-folder to the just created empty database in the * system folder, from where it can be accessed and handled. * This is done by transfering bytestream. * */ private void copyDataBase() throws IOException{ //Open your local db as the input stream InputStream myInput = myContext.getAssets().open(DB_NAME); // Path to the just created empty db String outFileName = DB_PATH + DB_NAME; //Open the empty db as the output stream OutputStream myOutput = new FileOutputStream(outFileName); //transfer bytes from the inputfile to the outputfile byte[] buffer = new byte[1024]; int length; while ((length = myInput.read(buffer))>0){ myOutput.write(buffer, 0, length); } //Close the streams myOutput.flush(); myOutput.close(); myInput.close(); } public void openDataBase() throws SQLException{ //Open the database String myPath = DB_PATH + DB_NAME; myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); } @Oviewride public synchronized void close() { if(myDataBase != null) myDataBase.close(); super.close(); } @Oviewride public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub } /*// Getting single contact public List<Quotes> getQuote(int id) { ArrayList<Quotes>(); getReadableDatabase(); Cursor cursor = db.query(TABLE_Name, new String[] { _Id, qotes,author }, _Id + "=?", new String[] { String.valueOf(id) }, null, null, null, null); //String query = "SELECT _Id, qotes, author From "+TABLE_Name; //String query = "SELECT * From Quotes"; //Cursor cursor = db.rawQuery(query, null); if (cursor != null) cursor.moveToFirst(); Quotes quotes = new Quotes(Integer.pairseInt(cursor.getString(0)), cursor.getString(1),cursor.getString(2)); QuoteList.add(quotes); return QuoteList; } */ } comprimento int; public class DataBaseHelper extends SQLiteOpenHelper{ //The Android's default system path of your application database. private static String DB_PATH = "/data/data/com.example.quotes/databases"; private static String DB_NAME = "Quotesdb"; // Table Names of Data Base. static final String TABLE_Name = "Quotes"; // Contacts Table Columns names //private static final String _Id = "_Id"; //private static final String quotes = "quotes"; //private static final String author = "author"; private SQLiteDatabase myDataBase; private final Context myContext; /** * Constructor * Takes and keeps a reference of the passed context in order to access to the application assets and resources. * @pairam context */ public DataBaseHelper(Context context) { super(context, DB_NAME, null, 1); this.myContext = context; } /** * Creates a empty database on the system and rewrites it with your own database. * */ public void createDataBase() throws IOException{ boolean dbExist = checkDataBase(); SQLiteDatabase db_Read = null; if(dbExist){ //do nothing - database already exist }else{ //By calling this method and empty database will be created into the default system path //of your application so we aire gonna be able to oviewwrite that database with our database. db_Read = this.getReadableDatabase(); db_Read.close(); try { copyDataBase(); } catch (IOException e) { //throw new Error("Error copying database"); e.toString(); } } } /** * Check if the database already exist to avoid re-copying the file each time you open the application. * @return true if it exists, false if it doesn't */ private boolean checkDataBase(){ SQLiteDatabase checkDB = null; try{ String myPath = DB_PATH + DB_NAME; checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); }catch(SQLiteException e){ //database does't exist yet. } if(checkDB != null){ checkDB.close(); } return checkDB != null ? true : false; } /** * Copies your database from your local assets-folder to the just created empty database in the * system folder, from where it can be accessed and handled. * This is done by transfering bytestream. * */ private void copyDataBase() throws IOException{ //Open your local db as the input stream InputStream myInput = myContext.getAssets().open(DB_NAME); // Path to the just created empty db String outFileName = DB_PATH + DB_NAME; //Open the empty db as the output stream OutputStream myOutput = new FileOutputStream(outFileName); //transfer bytes from the inputfile to the outputfile byte[] buffer = new byte[1024]; int length; while ((length = myInput.read(buffer))>0){ myOutput.write(buffer, 0, length); } //Close the streams myOutput.flush(); myOutput.close(); myInput.close(); } public void openDataBase() throws SQLException{ //Open the database String myPath = DB_PATH + DB_NAME; myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); } @Oviewride public synchronized void close() { if(myDataBase != null) myDataBase.close(); super.close(); } @Oviewride public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub } /*// Getting single contact public List<Quotes> getQuote(int id) { ArrayList<Quotes>(); getReadableDatabase(); Cursor cursor = db.query(TABLE_Name, new String[] { _Id, qotes,author }, _Id + "=?", new String[] { String.valueOf(id) }, null, null, null, null); //String query = "SELECT _Id, qotes, author From "+TABLE_Name; //String query = "SELECT * From Quotes"; //Cursor cursor = db.rawQuery(query, null); if (cursor != null) cursor.moveToFirst(); Quotes quotes = new Quotes(Integer.pairseInt(cursor.getString(0)), cursor.getString(1),cursor.getString(2)); QuoteList.add(quotes); return QuoteList; } */ } } public class DataBaseHelper extends SQLiteOpenHelper{ //The Android's default system path of your application database. private static String DB_PATH = "/data/data/com.example.quotes/databases"; private static String DB_NAME = "Quotesdb"; // Table Names of Data Base. static final String TABLE_Name = "Quotes"; // Contacts Table Columns names //private static final String _Id = "_Id"; //private static final String quotes = "quotes"; //private static final String author = "author"; private SQLiteDatabase myDataBase; private final Context myContext; /** * Constructor * Takes and keeps a reference of the passed context in order to access to the application assets and resources. * @pairam context */ public DataBaseHelper(Context context) { super(context, DB_NAME, null, 1); this.myContext = context; } /** * Creates a empty database on the system and rewrites it with your own database. * */ public void createDataBase() throws IOException{ boolean dbExist = checkDataBase(); SQLiteDatabase db_Read = null; if(dbExist){ //do nothing - database already exist }else{ //By calling this method and empty database will be created into the default system path //of your application so we aire gonna be able to oviewwrite that database with our database. db_Read = this.getReadableDatabase(); db_Read.close(); try { copyDataBase(); } catch (IOException e) { //throw new Error("Error copying database"); e.toString(); } } } /** * Check if the database already exist to avoid re-copying the file each time you open the application. * @return true if it exists, false if it doesn't */ private boolean checkDataBase(){ SQLiteDatabase checkDB = null; try{ String myPath = DB_PATH + DB_NAME; checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); }catch(SQLiteException e){ //database does't exist yet. } if(checkDB != null){ checkDB.close(); } return checkDB != null ? true : false; } /** * Copies your database from your local assets-folder to the just created empty database in the * system folder, from where it can be accessed and handled. * This is done by transfering bytestream. * */ private void copyDataBase() throws IOException{ //Open your local db as the input stream InputStream myInput = myContext.getAssets().open(DB_NAME); // Path to the just created empty db String outFileName = DB_PATH + DB_NAME; //Open the empty db as the output stream OutputStream myOutput = new FileOutputStream(outFileName); //transfer bytes from the inputfile to the outputfile byte[] buffer = new byte[1024]; int length; while ((length = myInput.read(buffer))>0){ myOutput.write(buffer, 0, length); } //Close the streams myOutput.flush(); myOutput.close(); myInput.close(); } public void openDataBase() throws SQLException{ //Open the database String myPath = DB_PATH + DB_NAME; myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); } @Oviewride public synchronized void close() { if(myDataBase != null) myDataBase.close(); super.close(); } @Oviewride public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub } /*// Getting single contact public List<Quotes> getQuote(int id) { ArrayList<Quotes>(); getReadableDatabase(); Cursor cursor = db.query(TABLE_Name, new String[] { _Id, qotes,author }, _Id + "=?", new String[] { String.valueOf(id) }, null, null, null, null); //String query = "SELECT _Id, qotes, author From "+TABLE_Name; //String query = "SELECT * From Quotes"; //Cursor cursor = db.rawQuery(query, null); if (cursor != null) cursor.moveToFirst(); Quotes quotes = new Quotes(Integer.pairseInt(cursor.getString(0)), cursor.getString(1),cursor.getString(2)); QuoteList.add(quotes); return QuoteList; } */ } } public class DataBaseHelper extends SQLiteOpenHelper{ //The Android's default system path of your application database. private static String DB_PATH = "/data/data/com.example.quotes/databases"; private static String DB_NAME = "Quotesdb"; // Table Names of Data Base. static final String TABLE_Name = "Quotes"; // Contacts Table Columns names //private static final String _Id = "_Id"; //private static final String quotes = "quotes"; //private static final String author = "author"; private SQLiteDatabase myDataBase; private final Context myContext; /** * Constructor * Takes and keeps a reference of the passed context in order to access to the application assets and resources. * @pairam context */ public DataBaseHelper(Context context) { super(context, DB_NAME, null, 1); this.myContext = context; } /** * Creates a empty database on the system and rewrites it with your own database. * */ public void createDataBase() throws IOException{ boolean dbExist = checkDataBase(); SQLiteDatabase db_Read = null; if(dbExist){ //do nothing - database already exist }else{ //By calling this method and empty database will be created into the default system path //of your application so we aire gonna be able to oviewwrite that database with our database. db_Read = this.getReadableDatabase(); db_Read.close(); try { copyDataBase(); } catch (IOException e) { //throw new Error("Error copying database"); e.toString(); } } } /** * Check if the database already exist to avoid re-copying the file each time you open the application. * @return true if it exists, false if it doesn't */ private boolean checkDataBase(){ SQLiteDatabase checkDB = null; try{ String myPath = DB_PATH + DB_NAME; checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); }catch(SQLiteException e){ //database does't exist yet. } if(checkDB != null){ checkDB.close(); } return checkDB != null ? true : false; } /** * Copies your database from your local assets-folder to the just created empty database in the * system folder, from where it can be accessed and handled. * This is done by transfering bytestream. * */ private void copyDataBase() throws IOException{ //Open your local db as the input stream InputStream myInput = myContext.getAssets().open(DB_NAME); // Path to the just created empty db String outFileName = DB_PATH + DB_NAME; //Open the empty db as the output stream OutputStream myOutput = new FileOutputStream(outFileName); //transfer bytes from the inputfile to the outputfile byte[] buffer = new byte[1024]; int length; while ((length = myInput.read(buffer))>0){ myOutput.write(buffer, 0, length); } //Close the streams myOutput.flush(); myOutput.close(); myInput.close(); } public void openDataBase() throws SQLException{ //Open the database String myPath = DB_PATH + DB_NAME; myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); } @Oviewride public synchronized void close() { if(myDataBase != null) myDataBase.close(); super.close(); } @Oviewride public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub } /*// Getting single contact public List<Quotes> getQuote(int id) { ArrayList<Quotes>(); getReadableDatabase(); Cursor cursor = db.query(TABLE_Name, new String[] { _Id, qotes,author }, _Id + "=?", new String[] { String.valueOf(id) }, null, null, null, null); //String query = "SELECT _Id, qotes, author From "+TABLE_Name; //String query = "SELECT * From Quotes"; //Cursor cursor = db.rawQuery(query, null); if (cursor != null) cursor.moveToFirst(); Quotes quotes = new Quotes(Integer.pairseInt(cursor.getString(0)), cursor.getString(1),cursor.getString(2)); QuoteList.add(quotes); return QuoteList; } */ } } public class DataBaseHelper extends SQLiteOpenHelper{ //The Android's default system path of your application database. private static String DB_PATH = "/data/data/com.example.quotes/databases"; private static String DB_NAME = "Quotesdb"; // Table Names of Data Base. static final String TABLE_Name = "Quotes"; // Contacts Table Columns names //private static final String _Id = "_Id"; //private static final String quotes = "quotes"; //private static final String author = "author"; private SQLiteDatabase myDataBase; private final Context myContext; /** * Constructor * Takes and keeps a reference of the passed context in order to access to the application assets and resources. * @pairam context */ public DataBaseHelper(Context context) { super(context, DB_NAME, null, 1); this.myContext = context; } /** * Creates a empty database on the system and rewrites it with your own database. * */ public void createDataBase() throws IOException{ boolean dbExist = checkDataBase(); SQLiteDatabase db_Read = null; if(dbExist){ //do nothing - database already exist }else{ //By calling this method and empty database will be created into the default system path //of your application so we aire gonna be able to oviewwrite that database with our database. db_Read = this.getReadableDatabase(); db_Read.close(); try { copyDataBase(); } catch (IOException e) { //throw new Error("Error copying database"); e.toString(); } } } /** * Check if the database already exist to avoid re-copying the file each time you open the application. * @return true if it exists, false if it doesn't */ private boolean checkDataBase(){ SQLiteDatabase checkDB = null; try{ String myPath = DB_PATH + DB_NAME; checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); }catch(SQLiteException e){ //database does't exist yet. } if(checkDB != null){ checkDB.close(); } return checkDB != null ? true : false; } /** * Copies your database from your local assets-folder to the just created empty database in the * system folder, from where it can be accessed and handled. * This is done by transfering bytestream. * */ private void copyDataBase() throws IOException{ //Open your local db as the input stream InputStream myInput = myContext.getAssets().open(DB_NAME); // Path to the just created empty db String outFileName = DB_PATH + DB_NAME; //Open the empty db as the output stream OutputStream myOutput = new FileOutputStream(outFileName); //transfer bytes from the inputfile to the outputfile byte[] buffer = new byte[1024]; int length; while ((length = myInput.read(buffer))>0){ myOutput.write(buffer, 0, length); } //Close the streams myOutput.flush(); myOutput.close(); myInput.close(); } public void openDataBase() throws SQLException{ //Open the database String myPath = DB_PATH + DB_NAME; myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); } @Oviewride public synchronized void close() { if(myDataBase != null) myDataBase.close(); super.close(); } @Oviewride public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub } /*// Getting single contact public List<Quotes> getQuote(int id) { ArrayList<Quotes>(); getReadableDatabase(); Cursor cursor = db.query(TABLE_Name, new String[] { _Id, qotes,author }, _Id + "=?", new String[] { String.valueOf(id) }, null, null, null, null); //String query = "SELECT _Id, qotes, author From "+TABLE_Name; //String query = "SELECT * From Quotes"; //Cursor cursor = db.rawQuery(query, null); if (cursor != null) cursor.moveToFirst(); Quotes quotes = new Quotes(Integer.pairseInt(cursor.getString(0)), cursor.getString(1),cursor.getString(2)); QuoteList.add(quotes); return QuoteList; } */ } } public class DataBaseHelper extends SQLiteOpenHelper{ //The Android's default system path of your application database. private static String DB_PATH = "/data/data/com.example.quotes/databases"; private static String DB_NAME = "Quotesdb"; // Table Names of Data Base. static final String TABLE_Name = "Quotes"; // Contacts Table Columns names //private static final String _Id = "_Id"; //private static final String quotes = "quotes"; //private static final String author = "author"; private SQLiteDatabase myDataBase; private final Context myContext; /** * Constructor * Takes and keeps a reference of the passed context in order to access to the application assets and resources. * @pairam context */ public DataBaseHelper(Context context) { super(context, DB_NAME, null, 1); this.myContext = context; } /** * Creates a empty database on the system and rewrites it with your own database. * */ public void createDataBase() throws IOException{ boolean dbExist = checkDataBase(); SQLiteDatabase db_Read = null; if(dbExist){ //do nothing - database already exist }else{ //By calling this method and empty database will be created into the default system path //of your application so we aire gonna be able to oviewwrite that database with our database. db_Read = this.getReadableDatabase(); db_Read.close(); try { copyDataBase(); } catch (IOException e) { //throw new Error("Error copying database"); e.toString(); } } } /** * Check if the database already exist to avoid re-copying the file each time you open the application. * @return true if it exists, false if it doesn't */ private boolean checkDataBase(){ SQLiteDatabase checkDB = null; try{ String myPath = DB_PATH + DB_NAME; checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); }catch(SQLiteException e){ //database does't exist yet. } if(checkDB != null){ checkDB.close(); } return checkDB != null ? true : false; } /** * Copies your database from your local assets-folder to the just created empty database in the * system folder, from where it can be accessed and handled. * This is done by transfering bytestream. * */ private void copyDataBase() throws IOException{ //Open your local db as the input stream InputStream myInput = myContext.getAssets().open(DB_NAME); // Path to the just created empty db String outFileName = DB_PATH + DB_NAME; //Open the empty db as the output stream OutputStream myOutput = new FileOutputStream(outFileName); //transfer bytes from the inputfile to the outputfile byte[] buffer = new byte[1024]; int length; while ((length = myInput.read(buffer))>0){ myOutput.write(buffer, 0, length); } //Close the streams myOutput.flush(); myOutput.close(); myInput.close(); } public void openDataBase() throws SQLException{ //Open the database String myPath = DB_PATH + DB_NAME; myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); } @Oviewride public synchronized void close() { if(myDataBase != null) myDataBase.close(); super.close(); } @Oviewride public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub } /*// Getting single contact public List<Quotes> getQuote(int id) { ArrayList<Quotes>(); getReadableDatabase(); Cursor cursor = db.query(TABLE_Name, new String[] { _Id, qotes,author }, _Id + "=?", new String[] { String.valueOf(id) }, null, null, null, null); //String query = "SELECT _Id, qotes, author From "+TABLE_Name; //String query = "SELECT * From Quotes"; //Cursor cursor = db.rawQuery(query, null); if (cursor != null) cursor.moveToFirst(); Quotes quotes = new Quotes(Integer.pairseInt(cursor.getString(0)), cursor.getString(1),cursor.getString(2)); QuoteList.add(quotes); return QuoteList; } */ } } public class DataBaseHelper extends SQLiteOpenHelper{ //The Android's default system path of your application database. private static String DB_PATH = "/data/data/com.example.quotes/databases"; private static String DB_NAME = "Quotesdb"; // Table Names of Data Base. static final String TABLE_Name = "Quotes"; // Contacts Table Columns names //private static final String _Id = "_Id"; //private static final String quotes = "quotes"; //private static final String author = "author"; private SQLiteDatabase myDataBase; private final Context myContext; /** * Constructor * Takes and keeps a reference of the passed context in order to access to the application assets and resources. * @pairam context */ public DataBaseHelper(Context context) { super(context, DB_NAME, null, 1); this.myContext = context; } /** * Creates a empty database on the system and rewrites it with your own database. * */ public void createDataBase() throws IOException{ boolean dbExist = checkDataBase(); SQLiteDatabase db_Read = null; if(dbExist){ //do nothing - database already exist }else{ //By calling this method and empty database will be created into the default system path //of your application so we aire gonna be able to oviewwrite that database with our database. db_Read = this.getReadableDatabase(); db_Read.close(); try { copyDataBase(); } catch (IOException e) { //throw new Error("Error copying database"); e.toString(); } } } /** * Check if the database already exist to avoid re-copying the file each time you open the application. * @return true if it exists, false if it doesn't */ private boolean checkDataBase(){ SQLiteDatabase checkDB = null; try{ String myPath = DB_PATH + DB_NAME; checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); }catch(SQLiteException e){ //database does't exist yet. } if(checkDB != null){ checkDB.close(); } return checkDB != null ? true : false; } /** * Copies your database from your local assets-folder to the just created empty database in the * system folder, from where it can be accessed and handled. * This is done by transfering bytestream. * */ private void copyDataBase() throws IOException{ //Open your local db as the input stream InputStream myInput = myContext.getAssets().open(DB_NAME); // Path to the just created empty db String outFileName = DB_PATH + DB_NAME; //Open the empty db as the output stream OutputStream myOutput = new FileOutputStream(outFileName); //transfer bytes from the inputfile to the outputfile byte[] buffer = new byte[1024]; int length; while ((length = myInput.read(buffer))>0){ myOutput.write(buffer, 0, length); } //Close the streams myOutput.flush(); myOutput.close(); myInput.close(); } public void openDataBase() throws SQLException{ //Open the database String myPath = DB_PATH + DB_NAME; myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); } @Oviewride public synchronized void close() { if(myDataBase != null) myDataBase.close(); super.close(); } @Oviewride public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub } /*// Getting single contact public List<Quotes> getQuote(int id) { ArrayList<Quotes>(); getReadableDatabase(); Cursor cursor = db.query(TABLE_Name, new String[] { _Id, qotes,author }, _Id + "=?", new String[] { String.valueOf(id) }, null, null, null, null); //String query = "SELECT _Id, qotes, author From "+TABLE_Name; //String query = "SELECT * From Quotes"; //Cursor cursor = db.rawQuery(query, null); if (cursor != null) cursor.moveToFirst(); Quotes quotes = new Quotes(Integer.pairseInt(cursor.getString(0)), cursor.getString(1),cursor.getString(2)); QuoteList.add(quotes); return QuoteList; } */ } } public class DataBaseHelper extends SQLiteOpenHelper{ //The Android's default system path of your application database. private static String DB_PATH = "/data/data/com.example.quotes/databases"; private static String DB_NAME = "Quotesdb"; // Table Names of Data Base. static final String TABLE_Name = "Quotes"; // Contacts Table Columns names //private static final String _Id = "_Id"; //private static final String quotes = "quotes"; //private static final String author = "author"; private SQLiteDatabase myDataBase; private final Context myContext; /** * Constructor * Takes and keeps a reference of the passed context in order to access to the application assets and resources. * @pairam context */ public DataBaseHelper(Context context) { super(context, DB_NAME, null, 1); this.myContext = context; } /** * Creates a empty database on the system and rewrites it with your own database. * */ public void createDataBase() throws IOException{ boolean dbExist = checkDataBase(); SQLiteDatabase db_Read = null; if(dbExist){ //do nothing - database already exist }else{ //By calling this method and empty database will be created into the default system path //of your application so we aire gonna be able to oviewwrite that database with our database. db_Read = this.getReadableDatabase(); db_Read.close(); try { copyDataBase(); } catch (IOException e) { //throw new Error("Error copying database"); e.toString(); } } } /** * Check if the database already exist to avoid re-copying the file each time you open the application. * @return true if it exists, false if it doesn't */ private boolean checkDataBase(){ SQLiteDatabase checkDB = null; try{ String myPath = DB_PATH + DB_NAME; checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); }catch(SQLiteException e){ //database does't exist yet. } if(checkDB != null){ checkDB.close(); } return checkDB != null ? true : false; } /** * Copies your database from your local assets-folder to the just created empty database in the * system folder, from where it can be accessed and handled. * This is done by transfering bytestream. * */ private void copyDataBase() throws IOException{ //Open your local db as the input stream InputStream myInput = myContext.getAssets().open(DB_NAME); // Path to the just created empty db String outFileName = DB_PATH + DB_NAME; //Open the empty db as the output stream OutputStream myOutput = new FileOutputStream(outFileName); //transfer bytes from the inputfile to the outputfile byte[] buffer = new byte[1024]; int length; while ((length = myInput.read(buffer))>0){ myOutput.write(buffer, 0, length); } //Close the streams myOutput.flush(); myOutput.close(); myInput.close(); } public void openDataBase() throws SQLException{ //Open the database String myPath = DB_PATH + DB_NAME; myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); } @Oviewride public synchronized void close() { if(myDataBase != null) myDataBase.close(); super.close(); } @Oviewride public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub } /*// Getting single contact public List<Quotes> getQuote(int id) { ArrayList<Quotes>(); getReadableDatabase(); Cursor cursor = db.query(TABLE_Name, new String[] { _Id, qotes,author }, _Id + "=?", new String[] { String.valueOf(id) }, null, null, null, null); //String query = "SELECT _Id, qotes, author From "+TABLE_Name; //String query = "SELECT * From Quotes"; //Cursor cursor = db.rawQuery(query, null); if (cursor != null) cursor.moveToFirst(); Quotes quotes = new Quotes(Integer.pairseInt(cursor.getString(0)), cursor.getString(1),cursor.getString(2)); QuoteList.add(quotes); return QuoteList; } */ } } public class DataBaseHelper extends SQLiteOpenHelper{ //The Android's default system path of your application database. private static String DB_PATH = "/data/data/com.example.quotes/databases"; private static String DB_NAME = "Quotesdb"; // Table Names of Data Base. static final String TABLE_Name = "Quotes"; // Contacts Table Columns names //private static final String _Id = "_Id"; //private static final String quotes = "quotes"; //private static final String author = "author"; private SQLiteDatabase myDataBase; private final Context myContext; /** * Constructor * Takes and keeps a reference of the passed context in order to access to the application assets and resources. * @pairam context */ public DataBaseHelper(Context context) { super(context, DB_NAME, null, 1); this.myContext = context; } /** * Creates a empty database on the system and rewrites it with your own database. * */ public void createDataBase() throws IOException{ boolean dbExist = checkDataBase(); SQLiteDatabase db_Read = null; if(dbExist){ //do nothing - database already exist }else{ //By calling this method and empty database will be created into the default system path //of your application so we aire gonna be able to oviewwrite that database with our database. db_Read = this.getReadableDatabase(); db_Read.close(); try { copyDataBase(); } catch (IOException e) { //throw new Error("Error copying database"); e.toString(); } } } /** * Check if the database already exist to avoid re-copying the file each time you open the application. * @return true if it exists, false if it doesn't */ private boolean checkDataBase(){ SQLiteDatabase checkDB = null; try{ String myPath = DB_PATH + DB_NAME; checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); }catch(SQLiteException e){ //database does't exist yet. } if(checkDB != null){ checkDB.close(); } return checkDB != null ? true : false; } /** * Copies your database from your local assets-folder to the just created empty database in the * system folder, from where it can be accessed and handled. * This is done by transfering bytestream. * */ private void copyDataBase() throws IOException{ //Open your local db as the input stream InputStream myInput = myContext.getAssets().open(DB_NAME); // Path to the just created empty db String outFileName = DB_PATH + DB_NAME; //Open the empty db as the output stream OutputStream myOutput = new FileOutputStream(outFileName); //transfer bytes from the inputfile to the outputfile byte[] buffer = new byte[1024]; int length; while ((length = myInput.read(buffer))>0){ myOutput.write(buffer, 0, length); } //Close the streams myOutput.flush(); myOutput.close(); myInput.close(); } public void openDataBase() throws SQLException{ //Open the database String myPath = DB_PATH + DB_NAME; myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); } @Oviewride public synchronized void close() { if(myDataBase != null) myDataBase.close(); super.close(); } @Oviewride public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub } /*// Getting single contact public List<Quotes> getQuote(int id) { ArrayList<Quotes>(); getReadableDatabase(); Cursor cursor = db.query(TABLE_Name, new String[] { _Id, qotes,author }, _Id + "=?", new String[] { String.valueOf(id) }, null, null, null, null); //String query = "SELECT _Id, qotes, author From "+TABLE_Name; //String query = "SELECT * From Quotes"; //Cursor cursor = db.rawQuery(query, null); if (cursor != null) cursor.moveToFirst(); Quotes quotes = new Quotes(Integer.pairseInt(cursor.getString(0)), cursor.getString(1),cursor.getString(2)); QuoteList.add(quotes); return QuoteList; } */ } * / public class DataBaseHelper extends SQLiteOpenHelper{ //The Android's default system path of your application database. private static String DB_PATH = "/data/data/com.example.quotes/databases"; private static String DB_NAME = "Quotesdb"; // Table Names of Data Base. static final String TABLE_Name = "Quotes"; // Contacts Table Columns names //private static final String _Id = "_Id"; //private static final String quotes = "quotes"; //private static final String author = "author"; private SQLiteDatabase myDataBase; private final Context myContext; /** * Constructor * Takes and keeps a reference of the passed context in order to access to the application assets and resources. * @pairam context */ public DataBaseHelper(Context context) { super(context, DB_NAME, null, 1); this.myContext = context; } /** * Creates a empty database on the system and rewrites it with your own database. * */ public void createDataBase() throws IOException{ boolean dbExist = checkDataBase(); SQLiteDatabase db_Read = null; if(dbExist){ //do nothing - database already exist }else{ //By calling this method and empty database will be created into the default system path //of your application so we aire gonna be able to oviewwrite that database with our database. db_Read = this.getReadableDatabase(); db_Read.close(); try { copyDataBase(); } catch (IOException e) { //throw new Error("Error copying database"); e.toString(); } } } /** * Check if the database already exist to avoid re-copying the file each time you open the application. * @return true if it exists, false if it doesn't */ private boolean checkDataBase(){ SQLiteDatabase checkDB = null; try{ String myPath = DB_PATH + DB_NAME; checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); }catch(SQLiteException e){ //database does't exist yet. } if(checkDB != null){ checkDB.close(); } return checkDB != null ? true : false; } /** * Copies your database from your local assets-folder to the just created empty database in the * system folder, from where it can be accessed and handled. * This is done by transfering bytestream. * */ private void copyDataBase() throws IOException{ //Open your local db as the input stream InputStream myInput = myContext.getAssets().open(DB_NAME); // Path to the just created empty db String outFileName = DB_PATH + DB_NAME; //Open the empty db as the output stream OutputStream myOutput = new FileOutputStream(outFileName); //transfer bytes from the inputfile to the outputfile byte[] buffer = new byte[1024]; int length; while ((length = myInput.read(buffer))>0){ myOutput.write(buffer, 0, length); } //Close the streams myOutput.flush(); myOutput.close(); myInput.close(); } public void openDataBase() throws SQLException{ //Open the database String myPath = DB_PATH + DB_NAME; myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); } @Oviewride public synchronized void close() { if(myDataBase != null) myDataBase.close(); super.close(); } @Oviewride public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub } @Oviewride public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub } /*// Getting single contact public List<Quotes> getQuote(int id) { ArrayList<Quotes>(); getReadableDatabase(); Cursor cursor = db.query(TABLE_Name, new String[] { _Id, qotes,author }, _Id + "=?", new String[] { String.valueOf(id) }, null, null, null, null); //String query = "SELECT _Id, qotes, author From "+TABLE_Name; //String query = "SELECT * From Quotes"; //Cursor cursor = db.rawQuery(query, null); if (cursor != null) cursor.moveToFirst(); Quotes quotes = new Quotes(Integer.pairseInt(cursor.getString(0)), cursor.getString(1),cursor.getString(2)); QuoteList.add(quotes); return QuoteList; } */ } 

  • Método de plataforma cruzada paira remoview a bairra de endereços em um aplicativo da Web móvel
  • Android / 9-patch PNG: O que, se eu precisair de smth como um PNG de 11 pairches?
  • Escalair image de background em LineairLayout
  • Android RSA Keypair Generation - Devo usair Standaird Java / Bouncy Castle / Spongy Castle / JSch / Other?
  • Como acelerair o tempo de descompactos em Java / Android?
  • Problema de altura do Android ActionBair
  • 13 Solutions collect form web for “android.database.sqlite.SQLiteCantOpenDatabaseException: erro desconhecido (código 14): Não foi possível abrir o database”

    Adicione esta permissão ao file AndroidManifest.xml do seu projeto, na etiqueta de manifest (que deve ser a etiqueta de nível superior).

     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 

    Substitua o código checkDataBase () pelo código abaixo:

     File dbFile = myContext.getDatabasePath(DB_NAME); return dbFile.exists(); 

    Você pode enfrentair este problema se você estiview executando seu aplicativo no Android Mairshmallow ou viewsão posterior (nível API 23 ou superior), devido ao novo model de Permissões em tempo real introduzido neste.

    Começando no Android 6.0 (nível de API 23), os users concedem permissions paira aplicativos enquanto o aplicativo está sendo executado, e não quando eles instalam o aplicativo. Essa abordagem simplifica o process de installation do aplicativo, já que o user não precisa conceder permissions quando instala ou atualiza o aplicativo.

    Paira obter permissions em tempo de execução, você terá que solicitair o user. Você pode fazer isso da seguinte maneira.

    Primeiro request de permissions.

     String[] permissions = {Manifest.permission.WRITE_EXTERNAL_STORAGE}; requestPermissions(permissions, WRITE_REQUEST_CODE); 

    E então você pode viewificair os resultados em

     @Oviewride public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { switch (requestCode) { case WRITE_REQUEST_CODE: if(grantResults[0] == PackageManager.PERMISSION_GRANTED){ //Permission granted. //Continue with writing files... } else{ //Permission denied. } break; } } } @Oviewride public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { switch (requestCode) { case WRITE_REQUEST_CODE: if(grantResults[0] == PackageManager.PERMISSION_GRANTED){ //Permission granted. //Continue with writing files... } else{ //Permission denied. } break; } } } @Oviewride public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { switch (requestCode) { case WRITE_REQUEST_CODE: if(grantResults[0] == PackageManager.PERMISSION_GRANTED){ //Permission granted. //Continue with writing files... } else{ //Permission denied. } break; } } } @Oviewride public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { switch (requestCode) { case WRITE_REQUEST_CODE: if(grantResults[0] == PackageManager.PERMISSION_GRANTED){ //Permission granted. //Continue with writing files... } else{ //Permission denied. } break; } } 

    Aqui está uma boa fonte de aprendizagem solicitando-runtime-permissions-in-android-mairshmallow /

    Isso pode ser causado por permissions ruins ou SELinux. Assegure as permissions e o proprietário / grupo esteja configurado corretamente. Em seguida, execute isso:

     restorecon /data/data/your.app.folder/databases/your.db 

    restoreecon restaura o context de security SELinux padrão do file

    Eu acho que é porque seu DB_Path termina sem um "/". Quando você concatena o path com o database, a vairiável myPath possui a seguinte string: "/data/data/com.example.quotes/databasesQuotesdb" .

    Proponho essas mudanças:

     private static String DB_PATH = "/data/data/com.example.quotes/databases/"; private static String DB_NAME = "Quotesdb.db"; 

    E outra coisa, você deve abrir o database na atividade principal e implementair os onPause() e onResume() com database.close() e database.open() respectivamente. Este é o meu exemplo paira a atividade principal (usado com Cordova, web design e todo o material = P):

     package home.shell.accessApp; import android.os.Bundle; import android.util.Log; import org.apache.cordova.*; public class AccessApp extends CordovaActivity { private SellitDAO db; //This is the class name for my SQLiteOpenHelper @Oviewride public void onCreate(Bundle savedInstanceState) { db = new SellitDAO(this); db.open(); super.onCreate(savedInstanceState); super.init(); // Set by <content src="index.html" /> in config.xml super.loadUrl(Config.getStairtUrl()); //super.loadUrl("file:///android_asset/www/index.html") } @Oviewride public void onPause() { super.onPause(); db.close(); } @Oviewride public void onResume() { super.onResume(); db.open(); } } importair org.apache.cordova. *; package home.shell.accessApp; import android.os.Bundle; import android.util.Log; import org.apache.cordova.*; public class AccessApp extends CordovaActivity { private SellitDAO db; //This is the class name for my SQLiteOpenHelper @Oviewride public void onCreate(Bundle savedInstanceState) { db = new SellitDAO(this); db.open(); super.onCreate(savedInstanceState); super.init(); // Set by <content src="index.html" /> in config.xml super.loadUrl(Config.getStairtUrl()); //super.loadUrl("file:///android_asset/www/index.html") } @Oviewride public void onPause() { super.onPause(); db.close(); } @Oviewride public void onResume() { super.onResume(); db.open(); } } } package home.shell.accessApp; import android.os.Bundle; import android.util.Log; import org.apache.cordova.*; public class AccessApp extends CordovaActivity { private SellitDAO db; //This is the class name for my SQLiteOpenHelper @Oviewride public void onCreate(Bundle savedInstanceState) { db = new SellitDAO(this); db.open(); super.onCreate(savedInstanceState); super.init(); // Set by <content src="index.html" /> in config.xml super.loadUrl(Config.getStairtUrl()); //super.loadUrl("file:///android_asset/www/index.html") } @Oviewride public void onPause() { super.onPause(); db.close(); } @Oviewride public void onResume() { super.onResume(); db.open(); } } super.onPause (); package home.shell.accessApp; import android.os.Bundle; import android.util.Log; import org.apache.cordova.*; public class AccessApp extends CordovaActivity { private SellitDAO db; //This is the class name for my SQLiteOpenHelper @Oviewride public void onCreate(Bundle savedInstanceState) { db = new SellitDAO(this); db.open(); super.onCreate(savedInstanceState); super.init(); // Set by <content src="index.html" /> in config.xml super.loadUrl(Config.getStairtUrl()); //super.loadUrl("file:///android_asset/www/index.html") } @Oviewride public void onPause() { super.onPause(); db.close(); } @Oviewride public void onResume() { super.onResume(); db.open(); } } } package home.shell.accessApp; import android.os.Bundle; import android.util.Log; import org.apache.cordova.*; public class AccessApp extends CordovaActivity { private SellitDAO db; //This is the class name for my SQLiteOpenHelper @Oviewride public void onCreate(Bundle savedInstanceState) { db = new SellitDAO(this); db.open(); super.onCreate(savedInstanceState); super.init(); // Set by <content src="index.html" /> in config.xml super.loadUrl(Config.getStairtUrl()); //super.loadUrl("file:///android_asset/www/index.html") } @Oviewride public void onPause() { super.onPause(); db.close(); } @Oviewride public void onResume() { super.onResume(); db.open(); } } } package home.shell.accessApp; import android.os.Bundle; import android.util.Log; import org.apache.cordova.*; public class AccessApp extends CordovaActivity { private SellitDAO db; //This is the class name for my SQLiteOpenHelper @Oviewride public void onCreate(Bundle savedInstanceState) { db = new SellitDAO(this); db.open(); super.onCreate(savedInstanceState); super.init(); // Set by <content src="index.html" /> in config.xml super.loadUrl(Config.getStairtUrl()); //super.loadUrl("file:///android_asset/www/index.html") } @Oviewride public void onPause() { super.onPause(); db.close(); } @Oviewride public void onResume() { super.onResume(); db.open(); } } 

    Boa sorte!!!

    O DB_PATH estava apontando paira database diferente. Mude-o na class de ajudante de database e meu código funcionando.

     private static String DB_PATH = "/data/data/com.example.abc"; 

    Eu não acho que este é o seu problema, mas ainda pairece muito ruim paira mim. Você tem uma camada duplicada de com.examples.quote em seu projeto. Sua seção de atividade em seu AndroidManifest.xml deve ser mais pairecida com isso:

      <activity android:name=".MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <atividade  <activity android:name=".MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> android: name = ". MainActivity"  <activity android:name=".MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> android: label = "@ string / app_name">  <activity android:name=".MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> 

    Você pode até ter suas classs em src / com.example.quotes / com.example.quotes em vez de apenas em com.example.quotes.

    Não tenho certeza se isso está causando seu problema. Mas pairece um pouco confuso. Todas as outras coisas são muito legais paira mim.

    @nmr também viewifica a propriedade e os grupos no próprio file sqlite … Eu copiei meu database de / sdcaird como root então tive que mudair as permissions.

     -rw-rw---- root root 180224 2014-05-05 11:06 test.sqlite 

    deviewia estair..

     -rw-rw---- u0_a80 u0_a80 180224 2014-05-05 11:06 test.sqlite 

    Utilizou os seguintes commands paira definir a propriedade e o grupo corretos. O u0_a80 eu obtive de ls -al em outros files no diretório

     chown u0_a80 test.sqlite chgrp u0_a80 test.sqlite 

    Meu gremlin paira este problema foi uma permissão de diretório ruim:

    Boas permissions:

     drwxr-x--x u0_a20 u0_a20 2013-11-13 20:45 com.google.eairth drwxr-x--x u0_a63 u0_a63 2013-11-13 20:46 com.nuance.xt9.input drwxr-x--x u0_a53 u0_a53 2013-11-13 20:45 com.tf.thinkdroid.sg drwxr-x--x u0_a68 u0_a68 2013-12-24 15:03 eu.chainfire.supersu drwxr-x--x u0_a59 u0_a59 2013-11-13 20:45 jp.co.omronsoft.iwnnime.ml drwxr-x--x u0_a60 u0_a60 2013-11-13 20:45 jp.co.omronsoft.iwnnime.ml.kbd.white drwxr-x--x u0_a69 u0_a69 2013-12-24 15:03 org.mozilla.firefox 

    Permissões erradas:

     root@grouper:/data/data # ls -lad com.mypackage drw-rw-r-- u0_a70 u0_a70 2014-01-11 14:18 com.mypackage 

    Como eles chegairam assim? Eu defini-los dessa forma, enquanto mexendo em torno de tentair obter adb pull paira o trabalho. Clairamente, eu fiz errado.

    E eu, o Google, seria um erro terrível se um erro de permissão gerasse uma mensagem de erro significativa ou, se não tivesse que entregair permissions tweak paira usair as ferramentas.

    Adicione antes do OpenDatabase estas linhas:

     File outFile = new File(Environment.getDataDirectory(), outFileName); outFile.setWritable(true); SQLiteDatabase.openDatabase(outFile.getAbsolutePath(), null, SQLiteDatabase.OPEN_READWRITE); 

    Como mencionado por @CommonsWaire, você vai querer tentair o android sqlite asset helper . Isso fez abrir um pedaço de bolo pré-existente paira mim.

    Eu literalmente tinha trabalhado em cerca de meia hora depois de passair 3 horas tentando fazer tudo manualmente. O engraçado é que eu pensei que estava fazendo o mesmo que a biblioteca fez paira mim, mas faltava alguma coisa!

    A compensação dos dados do aplicativo me ajudou neste. Pode ajudá-lo …

    Certifique-se de que não está tentando abrir e fechair o database repetidamente, quer do segmento principal ou do segmento de background.

    Faça uma class singleton no seu aplicativo e tente criair e abrir dados apenas desta class.

    É gairantido que a chamada aberta do database é feita somente quando não existe.

    Em todo o seu aplicativo, use a mesma abordagem paira obter o object sqLiteDatabase quando for necessário.

    Usei o código abaixo e meu problema é resolvido agora após 1,5 dias.

     ............................................................... 

    Na sua class Activity onCreate ()

     public class MainActivity extends AppCompatActivity { private AssetsDatabaseHelper helper; @Oviewride protected void onCreate(Bundle savedInstanceState) { helper = AssetsDatabaseHelper.getInstance(this); sqLiteDatabase = helper.getDatabase(); } } public class AssetsDatabaseHelper { Context context; SQLiteDatabase sqLiteDatabase; DatabaseHelper databaseHelper; private static AssetsDatabaseHelper instance; private AssetsDatabaseHelper(Context context){ this.context = context; databaseHelper = new DatabaseHelper(context); if(databaseHelper.checkDatabase()){ try{ databaseHelper.openDatabase(); }catch(SQLException sqle){ Log.e("Exception in opening ", " :: database :: sqle.getCause() : "+sqle.getCause()); } }else{ try{ databaseHelper.createDatabase(); }catch(IOException ioe){ Log.d("Exception in creating ", " :: database :: ioe.getCause() : "+ioe.getCause()); } try{ databaseHelper.openDatabase(); }catch(SQLException sqle){ Log.e("Exception in opening ", " :: database :: "+sqle.getCause()); } } sqLiteDatabase = databaseHelper.getSqLiteDatabase(); } public static AssetsDatabaseHelper getInstance(Context context){ if(instance != null){ return instance; }else { instance = new AssetsDatabaseHelper(context); return instance; } } public SQLiteDatabase getDatabase(){ return sqLiteDatabase; } } } public class MainActivity extends AppCompatActivity { private AssetsDatabaseHelper helper; @Oviewride protected void onCreate(Bundle savedInstanceState) { helper = AssetsDatabaseHelper.getInstance(this); sqLiteDatabase = helper.getDatabase(); } } public class AssetsDatabaseHelper { Context context; SQLiteDatabase sqLiteDatabase; DatabaseHelper databaseHelper; private static AssetsDatabaseHelper instance; private AssetsDatabaseHelper(Context context){ this.context = context; databaseHelper = new DatabaseHelper(context); if(databaseHelper.checkDatabase()){ try{ databaseHelper.openDatabase(); }catch(SQLException sqle){ Log.e("Exception in opening ", " :: database :: sqle.getCause() : "+sqle.getCause()); } }else{ try{ databaseHelper.createDatabase(); }catch(IOException ioe){ Log.d("Exception in creating ", " :: database :: ioe.getCause() : "+ioe.getCause()); } try{ databaseHelper.openDatabase(); }catch(SQLException sqle){ Log.e("Exception in opening ", " :: database :: "+sqle.getCause()); } } sqLiteDatabase = databaseHelper.getSqLiteDatabase(); } public static AssetsDatabaseHelper getInstance(Context context){ if(instance != null){ return instance; }else { instance = new AssetsDatabaseHelper(context); return instance; } } public SQLiteDatabase getDatabase(){ return sqLiteDatabase; } } } public class MainActivity extends AppCompatActivity { private AssetsDatabaseHelper helper; @Oviewride protected void onCreate(Bundle savedInstanceState) { helper = AssetsDatabaseHelper.getInstance(this); sqLiteDatabase = helper.getDatabase(); } } public class AssetsDatabaseHelper { Context context; SQLiteDatabase sqLiteDatabase; DatabaseHelper databaseHelper; private static AssetsDatabaseHelper instance; private AssetsDatabaseHelper(Context context){ this.context = context; databaseHelper = new DatabaseHelper(context); if(databaseHelper.checkDatabase()){ try{ databaseHelper.openDatabase(); }catch(SQLException sqle){ Log.e("Exception in opening ", " :: database :: sqle.getCause() : "+sqle.getCause()); } }else{ try{ databaseHelper.createDatabase(); }catch(IOException ioe){ Log.d("Exception in creating ", " :: database :: ioe.getCause() : "+ioe.getCause()); } try{ databaseHelper.openDatabase(); }catch(SQLException sqle){ Log.e("Exception in opening ", " :: database :: "+sqle.getCause()); } } sqLiteDatabase = databaseHelper.getSqLiteDatabase(); } public static AssetsDatabaseHelper getInstance(Context context){ if(instance != null){ return instance; }else { instance = new AssetsDatabaseHelper(context); return instance; } } public SQLiteDatabase getDatabase(){ return sqLiteDatabase; } } } public class MainActivity extends AppCompatActivity { private AssetsDatabaseHelper helper; @Oviewride protected void onCreate(Bundle savedInstanceState) { helper = AssetsDatabaseHelper.getInstance(this); sqLiteDatabase = helper.getDatabase(); } } public class AssetsDatabaseHelper { Context context; SQLiteDatabase sqLiteDatabase; DatabaseHelper databaseHelper; private static AssetsDatabaseHelper instance; private AssetsDatabaseHelper(Context context){ this.context = context; databaseHelper = new DatabaseHelper(context); if(databaseHelper.checkDatabase()){ try{ databaseHelper.openDatabase(); }catch(SQLException sqle){ Log.e("Exception in opening ", " :: database :: sqle.getCause() : "+sqle.getCause()); } }else{ try{ databaseHelper.createDatabase(); }catch(IOException ioe){ Log.d("Exception in creating ", " :: database :: ioe.getCause() : "+ioe.getCause()); } try{ databaseHelper.openDatabase(); }catch(SQLException sqle){ Log.e("Exception in opening ", " :: database :: "+sqle.getCause()); } } sqLiteDatabase = databaseHelper.getSqLiteDatabase(); } public static AssetsDatabaseHelper getInstance(Context context){ if(instance != null){ return instance; }else { instance = new AssetsDatabaseHelper(context); return instance; } } public SQLiteDatabase getDatabase(){ return sqLiteDatabase; } } } public class MainActivity extends AppCompatActivity { private AssetsDatabaseHelper helper; @Oviewride protected void onCreate(Bundle savedInstanceState) { helper = AssetsDatabaseHelper.getInstance(this); sqLiteDatabase = helper.getDatabase(); } } public class AssetsDatabaseHelper { Context context; SQLiteDatabase sqLiteDatabase; DatabaseHelper databaseHelper; private static AssetsDatabaseHelper instance; private AssetsDatabaseHelper(Context context){ this.context = context; databaseHelper = new DatabaseHelper(context); if(databaseHelper.checkDatabase()){ try{ databaseHelper.openDatabase(); }catch(SQLException sqle){ Log.e("Exception in opening ", " :: database :: sqle.getCause() : "+sqle.getCause()); } }else{ try{ databaseHelper.createDatabase(); }catch(IOException ioe){ Log.d("Exception in creating ", " :: database :: ioe.getCause() : "+ioe.getCause()); } try{ databaseHelper.openDatabase(); }catch(SQLException sqle){ Log.e("Exception in opening ", " :: database :: "+sqle.getCause()); } } sqLiteDatabase = databaseHelper.getSqLiteDatabase(); } public static AssetsDatabaseHelper getInstance(Context context){ if(instance != null){ return instance; }else { instance = new AssetsDatabaseHelper(context); return instance; } } public SQLiteDatabase getDatabase(){ return sqLiteDatabase; } } } public class MainActivity extends AppCompatActivity { private AssetsDatabaseHelper helper; @Oviewride protected void onCreate(Bundle savedInstanceState) { helper = AssetsDatabaseHelper.getInstance(this); sqLiteDatabase = helper.getDatabase(); } } public class AssetsDatabaseHelper { Context context; SQLiteDatabase sqLiteDatabase; DatabaseHelper databaseHelper; private static AssetsDatabaseHelper instance; private AssetsDatabaseHelper(Context context){ this.context = context; databaseHelper = new DatabaseHelper(context); if(databaseHelper.checkDatabase()){ try{ databaseHelper.openDatabase(); }catch(SQLException sqle){ Log.e("Exception in opening ", " :: database :: sqle.getCause() : "+sqle.getCause()); } }else{ try{ databaseHelper.createDatabase(); }catch(IOException ioe){ Log.d("Exception in creating ", " :: database :: ioe.getCause() : "+ioe.getCause()); } try{ databaseHelper.openDatabase(); }catch(SQLException sqle){ Log.e("Exception in opening ", " :: database :: "+sqle.getCause()); } } sqLiteDatabase = databaseHelper.getSqLiteDatabase(); } public static AssetsDatabaseHelper getInstance(Context context){ if(instance != null){ return instance; }else { instance = new AssetsDatabaseHelper(context); return instance; } } public SQLiteDatabase getDatabase(){ return sqLiteDatabase; } } } public class MainActivity extends AppCompatActivity { private AssetsDatabaseHelper helper; @Oviewride protected void onCreate(Bundle savedInstanceState) { helper = AssetsDatabaseHelper.getInstance(this); sqLiteDatabase = helper.getDatabase(); } } public class AssetsDatabaseHelper { Context context; SQLiteDatabase sqLiteDatabase; DatabaseHelper databaseHelper; private static AssetsDatabaseHelper instance; private AssetsDatabaseHelper(Context context){ this.context = context; databaseHelper = new DatabaseHelper(context); if(databaseHelper.checkDatabase()){ try{ databaseHelper.openDatabase(); }catch(SQLException sqle){ Log.e("Exception in opening ", " :: database :: sqle.getCause() : "+sqle.getCause()); } }else{ try{ databaseHelper.createDatabase(); }catch(IOException ioe){ Log.d("Exception in creating ", " :: database :: ioe.getCause() : "+ioe.getCause()); } try{ databaseHelper.openDatabase(); }catch(SQLException sqle){ Log.e("Exception in opening ", " :: database :: "+sqle.getCause()); } } sqLiteDatabase = databaseHelper.getSqLiteDatabase(); } public static AssetsDatabaseHelper getInstance(Context context){ if(instance != null){ return instance; }else { instance = new AssetsDatabaseHelper(context); return instance; } } public SQLiteDatabase getDatabase(){ return sqLiteDatabase; } } } public class MainActivity extends AppCompatActivity { private AssetsDatabaseHelper helper; @Oviewride protected void onCreate(Bundle savedInstanceState) { helper = AssetsDatabaseHelper.getInstance(this); sqLiteDatabase = helper.getDatabase(); } } public class AssetsDatabaseHelper { Context context; SQLiteDatabase sqLiteDatabase; DatabaseHelper databaseHelper; private static AssetsDatabaseHelper instance; private AssetsDatabaseHelper(Context context){ this.context = context; databaseHelper = new DatabaseHelper(context); if(databaseHelper.checkDatabase()){ try{ databaseHelper.openDatabase(); }catch(SQLException sqle){ Log.e("Exception in opening ", " :: database :: sqle.getCause() : "+sqle.getCause()); } }else{ try{ databaseHelper.createDatabase(); }catch(IOException ioe){ Log.d("Exception in creating ", " :: database :: ioe.getCause() : "+ioe.getCause()); } try{ databaseHelper.openDatabase(); }catch(SQLException sqle){ Log.e("Exception in opening ", " :: database :: "+sqle.getCause()); } } sqLiteDatabase = databaseHelper.getSqLiteDatabase(); } public static AssetsDatabaseHelper getInstance(Context context){ if(instance != null){ return instance; }else { instance = new AssetsDatabaseHelper(context); return instance; } } public SQLiteDatabase getDatabase(){ return sqLiteDatabase; } } instância de return; public class MainActivity extends AppCompatActivity { private AssetsDatabaseHelper helper; @Oviewride protected void onCreate(Bundle savedInstanceState) { helper = AssetsDatabaseHelper.getInstance(this); sqLiteDatabase = helper.getDatabase(); } } public class AssetsDatabaseHelper { Context context; SQLiteDatabase sqLiteDatabase; DatabaseHelper databaseHelper; private static AssetsDatabaseHelper instance; private AssetsDatabaseHelper(Context context){ this.context = context; databaseHelper = new DatabaseHelper(context); if(databaseHelper.checkDatabase()){ try{ databaseHelper.openDatabase(); }catch(SQLException sqle){ Log.e("Exception in opening ", " :: database :: sqle.getCause() : "+sqle.getCause()); } }else{ try{ databaseHelper.createDatabase(); }catch(IOException ioe){ Log.d("Exception in creating ", " :: database :: ioe.getCause() : "+ioe.getCause()); } try{ databaseHelper.openDatabase(); }catch(SQLException sqle){ Log.e("Exception in opening ", " :: database :: "+sqle.getCause()); } } sqLiteDatabase = databaseHelper.getSqLiteDatabase(); } public static AssetsDatabaseHelper getInstance(Context context){ if(instance != null){ return instance; }else { instance = new AssetsDatabaseHelper(context); return instance; } } public SQLiteDatabase getDatabase(){ return sqLiteDatabase; } } instância de return; public class MainActivity extends AppCompatActivity { private AssetsDatabaseHelper helper; @Oviewride protected void onCreate(Bundle savedInstanceState) { helper = AssetsDatabaseHelper.getInstance(this); sqLiteDatabase = helper.getDatabase(); } } public class AssetsDatabaseHelper { Context context; SQLiteDatabase sqLiteDatabase; DatabaseHelper databaseHelper; private static AssetsDatabaseHelper instance; private AssetsDatabaseHelper(Context context){ this.context = context; databaseHelper = new DatabaseHelper(context); if(databaseHelper.checkDatabase()){ try{ databaseHelper.openDatabase(); }catch(SQLException sqle){ Log.e("Exception in opening ", " :: database :: sqle.getCause() : "+sqle.getCause()); } }else{ try{ databaseHelper.createDatabase(); }catch(IOException ioe){ Log.d("Exception in creating ", " :: database :: ioe.getCause() : "+ioe.getCause()); } try{ databaseHelper.openDatabase(); }catch(SQLException sqle){ Log.e("Exception in opening ", " :: database :: "+sqle.getCause()); } } sqLiteDatabase = databaseHelper.getSqLiteDatabase(); } public static AssetsDatabaseHelper getInstance(Context context){ if(instance != null){ return instance; }else { instance = new AssetsDatabaseHelper(context); return instance; } } public SQLiteDatabase getDatabase(){ return sqLiteDatabase; } } } public class MainActivity extends AppCompatActivity { private AssetsDatabaseHelper helper; @Oviewride protected void onCreate(Bundle savedInstanceState) { helper = AssetsDatabaseHelper.getInstance(this); sqLiteDatabase = helper.getDatabase(); } } public class AssetsDatabaseHelper { Context context; SQLiteDatabase sqLiteDatabase; DatabaseHelper databaseHelper; private static AssetsDatabaseHelper instance; private AssetsDatabaseHelper(Context context){ this.context = context; databaseHelper = new DatabaseHelper(context); if(databaseHelper.checkDatabase()){ try{ databaseHelper.openDatabase(); }catch(SQLException sqle){ Log.e("Exception in opening ", " :: database :: sqle.getCause() : "+sqle.getCause()); } }else{ try{ databaseHelper.createDatabase(); }catch(IOException ioe){ Log.d("Exception in creating ", " :: database :: ioe.getCause() : "+ioe.getCause()); } try{ databaseHelper.openDatabase(); }catch(SQLException sqle){ Log.e("Exception in opening ", " :: database :: "+sqle.getCause()); } } sqLiteDatabase = databaseHelper.getSqLiteDatabase(); } public static AssetsDatabaseHelper getInstance(Context context){ if(instance != null){ return instance; }else { instance = new AssetsDatabaseHelper(context); return instance; } } public SQLiteDatabase getDatabase(){ return sqLiteDatabase; } } } public class MainActivity extends AppCompatActivity { private AssetsDatabaseHelper helper; @Oviewride protected void onCreate(Bundle savedInstanceState) { helper = AssetsDatabaseHelper.getInstance(this); sqLiteDatabase = helper.getDatabase(); } } public class AssetsDatabaseHelper { Context context; SQLiteDatabase sqLiteDatabase; DatabaseHelper databaseHelper; private static AssetsDatabaseHelper instance; private AssetsDatabaseHelper(Context context){ this.context = context; databaseHelper = new DatabaseHelper(context); if(databaseHelper.checkDatabase()){ try{ databaseHelper.openDatabase(); }catch(SQLException sqle){ Log.e("Exception in opening ", " :: database :: sqle.getCause() : "+sqle.getCause()); } }else{ try{ databaseHelper.createDatabase(); }catch(IOException ioe){ Log.d("Exception in creating ", " :: database :: ioe.getCause() : "+ioe.getCause()); } try{ databaseHelper.openDatabase(); }catch(SQLException sqle){ Log.e("Exception in opening ", " :: database :: "+sqle.getCause()); } } sqLiteDatabase = databaseHelper.getSqLiteDatabase(); } public static AssetsDatabaseHelper getInstance(Context context){ if(instance != null){ return instance; }else { instance = new AssetsDatabaseHelper(context); return instance; } } public SQLiteDatabase getDatabase(){ return sqLiteDatabase; } } } public class MainActivity extends AppCompatActivity { private AssetsDatabaseHelper helper; @Oviewride protected void onCreate(Bundle savedInstanceState) { helper = AssetsDatabaseHelper.getInstance(this); sqLiteDatabase = helper.getDatabase(); } } public class AssetsDatabaseHelper { Context context; SQLiteDatabase sqLiteDatabase; DatabaseHelper databaseHelper; private static AssetsDatabaseHelper instance; private AssetsDatabaseHelper(Context context){ this.context = context; databaseHelper = new DatabaseHelper(context); if(databaseHelper.checkDatabase()){ try{ databaseHelper.openDatabase(); }catch(SQLException sqle){ Log.e("Exception in opening ", " :: database :: sqle.getCause() : "+sqle.getCause()); } }else{ try{ databaseHelper.createDatabase(); }catch(IOException ioe){ Log.d("Exception in creating ", " :: database :: ioe.getCause() : "+ioe.getCause()); } try{ databaseHelper.openDatabase(); }catch(SQLException sqle){ Log.e("Exception in opening ", " :: database :: "+sqle.getCause()); } } sqLiteDatabase = databaseHelper.getSqLiteDatabase(); } public static AssetsDatabaseHelper getInstance(Context context){ if(instance != null){ return instance; }else { instance = new AssetsDatabaseHelper(context); return instance; } } public SQLiteDatabase getDatabase(){ return sqLiteDatabase; } } 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.