I really don't know what method to use! all right, i have this: copyfile(context,"data/data/ carburant.android.com/files/alaa.peugeot.settings.dat",sdCard.getAbsolutePath() + "/Carburant/storeddata.dat");
I have to replace "data/data/ carburant.android.com/files/alaa.peugeot.settings.dat" by a method. Have i to use this? getFileStreamPath<http://developer.android.com/reference/android/content/Context.html#getFileStreamPath(java.lang.String)> (String <http://developer.android.com/reference/java/lang/String.html> name) Returns the absolute path on the filesystem where a file created with openFileOutput(String, int)<http://developer.android.com/reference/android/content/Context.html#openFileOutput(java.lang.String, int)> is stored. But the file created in the /data/data...... is not created with openFileOutput(String, int)<http://developer.android.com/reference/android/content/Context.html#openFileOutput(java.lang.String, int)> 2011/4/4 Kostya Vasilyev <kmans...@gmail.com> > A few things. > > 1 - For the target file, don't use "SDCARD" in your paths. > Environment.getExternalStorageDirectory already gives you the path to the > top-level directory ("root") of the memory card. > > Android 2.2 uses a path that's different from earlier versions, and you can > rely on this function to do right thing. > > 2 - For the source file, use this: > > > http://developer.android.com/reference/android/content/Context.html#openFileInput(java.lang.String > ) > > or > > > http://developer.android.com/reference/android/content/Context.html#openFileOutput(java.lang.String, > int) > > Do not try to build the full path yourself (as in, > "/data/data/<package_name>/files") - the path can be different depending on > the device and its Android version. The above functions already take care of > that. > > You already have code to read your data files (to populate the list view), > just do it the same way. > > -- Kostya > > 2011/4/4 Alaeddine Ghribi <alaeddineghr...@gmail.com> > >> So i maked this: >> catch(FileNotFoundException ex){ >> Toast.makeText(context, "File Not found", >> Toast.LENGTH_SHORT).show(); >> String x=ex.getMessage(); >> Log.d("Carburant", x); >> } >> >> Here is the message i get: >> 04-04 11:07:20.851: DEBUG/Carburant(377): /alaa.peugeot.settings.dat (No >> such file or directory) >> >> So as the log indicated, the compiler doesn't finds the file in the >> /data/data... >> I maked one other thing, in the copyfile function i maked this: >> copyfile(context,*"data/data/ >> carburant.android.com/files/alaa.peugeot.settings.dat"*,sdCard.getAbsolutePath() >> + "/SDCARD/Carburant/storeddata.dat"); >> >> The log message now indicates this: >> 04-04 11:11:32.771: DEBUG/Carburant(852): >> /mnt/sdcard/SDCARD/Carburant/storeddata.dat (Permission denied) >> >> Let's begin to correct the first message :\ >> Every user will put its name and car mark, so this 2 variables are not >> constant! >> So, in the menu export code i maked this: >> case R.id.exporter: >> 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); >> //Import myImport(this, fileDir+fileName); >> myImport.transfer(); >> return true; >> >> I think that the problem comes from the red line, it's a comment because i >> always have an error message on it, but i think that this line can make the >> problem solved, we have to import in the "import" function the filedir and >> filename, without this line, nothing imported => it can't find the file in >> the /data/data... >> >> So please what can i put to import the necessary variables to the import >> function(in the other class). >> Thank you. >> >> >> >> 2011/4/4 TreKing <treking...@gmail.com> >> >>> On Sun, Apr 3, 2011 at 9:11 PM, Alaeddine Ghribi < >>> alaeddineghr...@gmail.com> wrote: >>> >>>> So i put a breakpoint in the catch line and in the debugger i think that >>>> i have the right variables: >>> >>> >>> Put a break at the *start* of your code and *step through* line by line >>> until you hit the line that causes the exception. >>> >>> OR >>> >>> Print the message the exception gives you (ex.getMessage()) to find out >>> what file is giving the error. >>> >>> >>> >>> ------------------------------------------------------------------------------------------------- >>> 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 >>> >> >> -- >> 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 >> > > -- > 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 > -- 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