I added a virtual SDCARD and the file is not exported ! I have a
storeddata.dat directory :\ ! Plus, i have a file not found exception
when tapping in the menu option "export" !
Any idea ?

On 3 avr, 16:06, Alaeddine Ghribi <alaeddineghr...@gmail.com> wrote:
> I solved the half of the problem for now, however, i'm having a File
> Not Found exception ! why the file is not copied ? How can i verify
> the file in the SDCARD in the emulator ?
> Thanks.
>
> On 3 avr, 15:42, Alaeddine Ghribi <alaeddineghr...@gmail.com> wrote:
>
>
>
>
>
>
>
> > 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 <alaeddineghr...@gmail.com> wrote:
>
> > > Nothing happens when i tap in the menu option button "Export" !
>
> > > On 3 avr, 03:54, TreKing <treking...@gmail.com> wrote:
>
> > > > On Sat, Apr 2, 2011 at 8:40 PM, Alaeddine Ghribi
> > > > <alaeddineghr...@gmail.com>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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to