Sorry for trivial question, I've a .db
sqlite3 file that I'm suppose to take data, e.g. it's read-only. But I'm wondering where to import it, while taking the path of this data file in order to connect it? Can you help me?
Asked
Active
Viewed 66 times
0

elgolondrino
- 665
- 9
- 33
-
Sorry, could you be more specific? – elgolondrino Jan 06 '14 at 17:07
-
on assets folder if is a pre populated DB: http://stackoverflow.com/questions/2409126/android-pre-populated-database – sabadow Jan 06 '14 at 17:12
2 Answers
0
import it following path
"/data/data/ur_package_name/databases/"

Sush
- 3,864
- 2
- 17
- 35
-
I'm solely aware of 'DRAG AND DROP' :) in eclipse, how to do that programmatically? By the way, *.db is already created! – elgolondrino Jan 06 '14 at 17:24
0
In my project I have a folder under the project called assets, I put my *.db there and load the database like this:
private static void copyDatabase(String dbname) throws IOException {
InputStream is = mContext.getAssets().open(dbname);
String outFileName = DB_PATH + dbname;
OutputStream out = new FileOutputStream(outFileName);
byte[] buffer = new byte[1024];
int length;
while ((length = is.read(buffer)) > 0) {
out.write(buffer, 0, length);
}
is.close();
out.flush();
out.close();
}

GhostDerfel
- 1,533
- 1
- 11
- 18