Snippet that copies a db to resources/raw for distribution?

Put your problem here if it does not fit any of the other categories.

Snippet that copies a db to resources/raw for distribution?

Postby Omar » Mon Mar 17, 2008 9:00 pm


My app contains a sqlite db that will be opened by the end user.
So far I have tried an approach I have found to place the text file in the resources/raw. From there I will read it and generate the db.
I am wondering though, is there an easier approach?
With this approach I am pursuing, so far I am running into the issue that the exception is kicking in, rather than the file being displayed. The file is in the resources.ap_ though.

private void readFileFromLocal( Context context )
InputStream istream = null;
try {
istream = context.getResources().openRawResource(R.raw.out2);
String s;
int i;, 0,100);
s = b +"";

} catch (Exception FileNotFoundException){
Log.v("File not found exception!", "hoy");

Is there some snippet out there that copies the SQLite db to resources/raw and from there it can be simply copied to the filessytem? I have found some methods under "mkdir", "create" and "rename" file, but not "copy":

String path2 = "/data/data/";
File dir = new File(path2);
File temp = File.createTempFile("mediaplayertmp",".txt", file);

Many thanks for your help,
Omar F
Posts: 2
Joined: Mon Mar 17, 2008 8:40 pm
Location: Reston


Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 6 guests