I edited the code to a one more correct:
public class Import {
        private Context context;
        private String nom;


    public Import(Context context,String nom) {
        this.context = context;
        this.nom=nom;
       }

        public void transfer(){

        File sdCard = Environment.getExternalStorageDirectory();
        File dir = new File (sdCard.getAbsolutePath() + "/SDCARD/Carburant/
storeddata.dat");
        dir.mkdirs();
        Toast.makeText(context, "Test", Toast.LENGTH_SHORT).show();
        copyfile(context,nom,sdCard.getAbsolutePath() + "/SDCARD/Carburant/
storeddata.dat");

}

        private void copyfile(Context context,String srFile, String dtFile){
            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();
            }
          }

        }

I hope that it's correct, but how the code could be when tapping in
the "export" option menu?
I maked this and nothing happens:
case R.id.importer:
                final SharedPreferences preferences = PreferenceManager
                        .getDefaultSharedPreferences(context);
        String fileName = getResources().getString(R.string.fileName);
        fileDir = "" + preferences.getString("login", "") + "."+
preferences.getString("marque", "") + ".";
    Import myImport = new Import(this,fileDir+fileName);
                myImport.transfer();
                return true;

Thank you for your answer.

On 3 avr, 12:06, Alaeddine Ghribi <[email protected]> wrote:
> Nothing happens when i tap in the menu option button "Export" !
>
> On 3 avr, 03:54, TreKing <[email protected]> wrote:
>
>
>
>
>
>
>
> > On Sat, Apr 2, 2011 at 8:40 PM, Alaeddine Ghribi
> > <[email protected]>wrote:
>
> > > I have a problem in the Import class that i can't recognize it !
>
> > What does that mean?
>
> > --------------------------------------------------------------------------- 
> > ----------------------
> > TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
> > transit tracking app for Android-powered devices

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