howto copy a large file from /res/raw to /data/data/PACKAGE/databases

  • Replies:6
  • OpenNot stickiedUnanswered
  • Forum posts: 286

Aug 8, 2010, 3:08:56 PM via Website

Hi All,

I tried the solution described on , which explains how to deploy a preloaded sqlite db with your app.
It works fine with small files, but my 1.5 MB sqlite.db can't be copied. ( with 125 kb it works ) . With 1.5 MB i get an ioexception.

Is there a filesize restriction in the filesystem of android ?

Is there a solution for copying large files ?

My code for this:
private void testcopyDataBase() {

//Open your local db as the input stream
InputStream myInput = this.getResources().openRawResource(R.raw.mydb);

// Path to the just created empty db
String outFileName = "/data/data/PACKAGE/databases/history10.db";

//Open the empty db as the output stream
OutputStream myOutput;
try {
myOutput = new FileOutputStream(outFileName);
//transfer bytes from the inputfile to the outputfile
byte[] buffer = new byte[1024];
int length;
while ((length =>0){
myOutput.write(buffer, 0, length);
//Close the streams
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block

  • Forum posts: 286

Aug 9, 2010, 9:02:48 PM via App

i get the error on the read line. no gui. simple read. as mentoined , if the file as smaller i can read it. i see that in bug mode eclipse.

  • Forum posts: 775

Aug 10, 2010, 6:42:38 AM via Website

I found a post that says that the max filesize for raw and assets, is about 1mb, but he also posted a solution.

The @ symbol messes up the link, copy and paste the whole link in your address bar.

— modified on Aug 10, 2010, 6:43:41 AM

  • Forum posts: 1

May 12, 2011, 6:00:49 AM via Website

okay, I've read the tutorial, but I'm still confused about one thing..
where should I put the database?? should I put it in the folder named assets or /res/raw???
because I read in that tutorial, it's said that we must put it in asset folder.
After I tried it and ran it, I got force close...

So, what's the solution????
Need help please....

  • Forum posts: 1

Oct 26, 2012, 2:12:45 PM via Website

hi frnd i need your help
i want to copy from res/raw to android/data/obb
so please help me how could i do this please reply full and correct code and tell me which files i need to modify
i dont good in codes