Hi, Kostya.

Hard coding aside (i agree its not the best practice), i have methods
verifying that the paths are indeed correct. I'm uncertain why it
works in eclipse but not on the device



On Oct 20, 12:30 pm, Kostya Vasilyev <[email protected]> wrote:
> Don't hard code the paths.
>
> For the database path, use context.getDatabasePath
>
> For the sdcard, use Environment.getExternalStorageDirectory
>
> -- Kostya
>
> 2011/10/20 Ab Caballero <[email protected]>
>
>
>
> > Hi,
> > I am attempting to copy a file from internal storage like so:
>
> > void exportDB() throws IOException {
> >          InputStream input = new FileInputStream("/data/data/
> > com.drayagerecorder/databases/DB");
>
> >          // create directory for backup
> >          checkStorage();
> >          File dir = new File("/sdcard/DB");
> >          dir.mkdir();
>
> >          // Path to the external backup
> >          OutputStream output = new FileOutputStream("/sdcard/DB/"+
> > currentName +"_db");
>
> >          // transfer bytes from the Input File to the Output File
> >          byte[] buffer = new byte[1024];
> >          int length;
> >          while ((length = input.read(buffer))>0) {
> >              output.write(buffer, 0, length);
> >          }
>
> > It works in eclipse but does not work on the device. Am i accessing
> > the internal storage correctly? The external storage is checked and is
> > available
>
> >          output.flush();
> >          output.close();
> >          input.close();
> >         }
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to