Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>to open a db from Assets use</p> <pre><code>AssetManager am = myContext.getAssets(); InputStream is = am.open("DB Name"); </code></pre> <p><code>Another related question I have is about the path. I've checked the files on my testing phone (samsung galaxy sII) but I don't see a /data/data/mypackagename/..</code></p> <p>You can not see your DB on your device due to security. If you actually want to see your DB. Then you need to install your App on Emulator</p> <p>EDIT:</p> <p>Code to copy the database</p> <pre><code> private static String db_path = "/data/data/your.package.name/databases/"; private static final String database_name = "search"; private void copyDataBase() throws IOException { String outFileName = db_path + database_name+".db"; // 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 i, r; AssetManager am = myContext.getAssets(); String fn = String.format(database_name); InputStream is = am.open(fn); while ((r = is.read(buffer)) != -1) myOutput.write(buffer, 0, r); is.close(); // Close the streams myOutput.flush(); myOutput.close(); } </code></pre> <p>to check DB </p> <pre><code>private boolean checkDataBase() { SQLiteDatabase checkDB = null; try { String myPath = db_path + database_name+".db"; checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.NO_LOCALIZED_COLLATORS); } catch (SQLiteException e) { // database does't exist yet. } if (checkDB != null) { checkDB.close(); } return checkDB != null ? true : false; } </code></pre> <p>MAKE sure you have added </p> <p><code>&lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;</code></p> <p>in you <code>manifest file</code>.</p>
    singulars
    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.
    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