Note that there are some explanatory texts on larger screens.

plurals
  1. POcopy existing database on SD card
    primarykey
    data
    text
    <p>When I am running android application it stores its database directly on the internal memory of the emulator. The application (.apk file) is stored on external storage. The size of the database is 230MB. I have the following lines in my manifest.xml:</p> <pre><code>&lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt; &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /&gt; &lt;manifest android:installLocation="preferExternal" &gt; </code></pre> <p>and the following code that results in the error, INSTALL_FAILED_DEXOPT :</p> <pre><code>public void copyDatabase() throws IOException { if(!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { Toast.makeText(mycontext,"External Sd card not mounted", Toast.LENGTH_LONG).show(); } try { InputStream in=mycontext.getAssets().open("Demo.db"); File outFile =new File(Environment.getExternalStorageDirectory()+File.separator+ "Demo.db); outFile.createNewFile(); OutputStream out= new FileOutputStream(outFile); byte[] buf = new byte[1024]; int len; while((len = in.read(buf))&gt; 0) { out.write(buf,0,len); } out.close(); in.close(); Log.i("copyDatabase","Database Has been transferred"); } catch(IOException e) { Log.i("CopyDatabase","could not copy database"); } } public boolean checkDatabase() { SQLiteDatabase checkdb=null; try { String myPath="/sdcard/demo.db"; checkdb=SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); Log.i("checkDatabase database path",checkdb.getPath()); } catch(SQLiteException e) { Log.e("Database doesn`t exist",e.toString()); } if(checkdb!=null) { checkdb.close(); } return checkdb != null ? true : false; } public void openDatabase() throws SQLException { String myPath="/sdcard/demo.db" myDatabase=SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READWRITE); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload