Hi,
I have data stored in a file in /data/data.... and i want to export it
to the SDCARD, i writed the code(wondering if it's correct) and the
class is not called, please try to help me to solve the problem, THANK
YOU:
public class Import extends Saves {
        private Context context;

        public void transfer(){
        context = getApplicationContext();
        File sdCard = Environment.getExternalStorageDirectory();
        File dir = new File (sdCard.getAbsolutePath() + "/SDCARD/Carburant/
storeddata.dat");
        dir.mkdirs();
        Toast.makeText(Import.this, "Test", Toast.LENGTH_SHORT).show();
        copyfile(context,"/data/data/carburant.android.com/files/",
                        sdCard.getAbsolutePath() + 
"/SDCARD/Carburant/storeddata.dat");

}

        private void copyfile(Context context,String srFile, String dtFile){
                context = getApplicationContext();
            try{
                File f1 = new File(srFile);
                File f2 = new File(dtFile);
              InputStream in = new FileInputStream(f1);
              OutputStream out = new FileOutputStream(f2);

              byte[] buf = new byte[1024];
              int len;
              while ((len = in.read(buf)) > 0){
                out.write(buf, 0, len);
              }
              in.close();
              out.close();
              Toast.makeText(context, "Export effectué",
Toast.LENGTH_SHORT).show();
            }
            catch(FileNotFoundException ex){
                Toast.makeText(context, "File Not found",
Toast.LENGTH_SHORT).show();
            }
            catch(IOException e){
                Toast.makeText(context, "Echec",
Toast.LENGTH_SHORT).show();
            }
          }

        }

-- 
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