[android-developers] Re: Import/Export data file
For storing a picture, here is the code: File file = new File(getExternalFilesDir(null), DemoFile.jpg); For storing the data file from /data/data: File file = new File(getExternalFilesDir(/data/data.), storedfile); Is that true ? On 1 avr, 02:03, Alaeddine Ghribi alaeddineghr...@gmail.com wrote: I assembled some codes to have this example: IS THAT TRUE ? boolean mExternalStorageAvailable = false; boolean mExternalStorageWriteable = false; String state = Environment.getExternalStorageState(); if (Environment.MEDIA_MOUNTED.equals(state)) { // We can read and write the media mExternalStorageAvailable = mExternalStorageWriteable = true; } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) { // We can only read the media mExternalStorageAvailable = true; mExternalStorageWriteable = false; } else { // Something else is wrong. It may be one of many other states, but all we need // to know is we can neither read nor write mExternalStorageAvailable = mExternalStorageWriteable = false; } void createExternalStoragePrivateFile() { // Create a path where we will place our private file on external // storage. File file = new File(getExternalFilesDir(null), DemoFile.jpg); try { // Very simple code to copy a picture from the application's // resource into the external file. Note that this code does // no error checking, and assumes the picture is small (does not // try to copy it in chunks). Note that if external storage is // not currently mounted this will silently fail. InputStream is = getResources().openRawResource(R.drawable.balloons); OutputStream os = new FileOutputStream(file); byte[] data = new byte[is.available()]; is.read(data); os.write(data); is.close(); os.close(); } catch (IOException e) { // Unable to create file, likely because external storage is // not currently mounted. Log.w(ExternalStorage, Error writing + file, e); } } void deleteExternalStoragePrivateFile() { // Get path for the file on external storage. If external // storage is not currently mounted this will fail. File file = new File(getExternalFilesDir(null), DemoFile.jpg); if (file != null) { file.delete(); } } boolean hasExternalStoragePrivateFile() { // Get path for the file on external storage. If external // storage is not currently mounted this will fail. File file = new File(getExternalFilesDir(null), DemoFile.jpg); if (file != null) { return file.exists(); } return false; } } In this example he copied a picture from the app, but me i want to copy the file data on /data/data.. ! how doing it ? Thank you :). On 30 mar, 14:05, Kostya Vasilyev kmans...@gmail.com wrote: 30.03.2011 22:00, Alaeddine Ghribi пишет: Ah okay i think that i understand the point now ! 1st link: how to copy two file. 2nd link: where to copy it. That's it ? That's right! -- Kostya Vasilyev --http://kmansoft.wordpress.com -- 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
Re: [android-developers] Re: Import/Export data file
On 1 April 2011 12:32, Alaeddine Ghribi alaeddineghr...@gmail.com wrote: For storing a picture, here is the code: File file = new File(getExternalFilesDir(null), DemoFile.jpg); For pictures I'd rather use: File path = getExternalFilesDir(Environment.DIRECTORY_PICTURES); to get the right path Regards, Marcin Orlowski *Tray Agenda http://bit.ly/trayagenda* - keep you daily schedule handy... WebnetMobile on *Facebook http://webnetmobile.com/fb/* and *Twitterhttp://webnetmobile.com/twitter/ * -- 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
[android-developers] Re: Import/Export data file
And how to do it if i want tp copy a file from /data/data/android/ android.dat to a directory android in the SDCARD ? Thanks :). On 1 avr, 12:10, Marcin Orlowski webnet.andr...@gmail.com wrote: On 1 April 2011 12:32, Alaeddine Ghribi alaeddineghr...@gmail.com wrote: For storing a picture, here is the code: File file = new File(getExternalFilesDir(null), DemoFile.jpg); For pictures I'd rather use: File path = getExternalFilesDir(Environment.DIRECTORY_PICTURES); to get the right path Regards, Marcin Orlowski *Tray Agenda http://bit.ly/trayagenda* - keep you daily schedule handy... WebnetMobile on *Facebook http://webnetmobile.com/fb/* and *Twitterhttp://webnetmobile.com/twitter/ * -- 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
[android-developers] Re: Import/Export data file
I assembled some codes to have this example: IS THAT TRUE ? boolean mExternalStorageAvailable = false; boolean mExternalStorageWriteable = false; String state = Environment.getExternalStorageState(); if (Environment.MEDIA_MOUNTED.equals(state)) { // We can read and write the media mExternalStorageAvailable = mExternalStorageWriteable = true; } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) { // We can only read the media mExternalStorageAvailable = true; mExternalStorageWriteable = false; } else { // Something else is wrong. It may be one of many other states, but all we need // to know is we can neither read nor write mExternalStorageAvailable = mExternalStorageWriteable = false; } void createExternalStoragePrivateFile() { // Create a path where we will place our private file on external // storage. File file = new File(getExternalFilesDir(null), DemoFile.jpg); try { // Very simple code to copy a picture from the application's // resource into the external file. Note that this code does // no error checking, and assumes the picture is small (does not // try to copy it in chunks). Note that if external storage is // not currently mounted this will silently fail. InputStream is = getResources().openRawResource(R.drawable.balloons); OutputStream os = new FileOutputStream(file); byte[] data = new byte[is.available()]; is.read(data); os.write(data); is.close(); os.close(); } catch (IOException e) { // Unable to create file, likely because external storage is // not currently mounted. Log.w(ExternalStorage, Error writing + file, e); } } void deleteExternalStoragePrivateFile() { // Get path for the file on external storage. If external // storage is not currently mounted this will fail. File file = new File(getExternalFilesDir(null), DemoFile.jpg); if (file != null) { file.delete(); } } boolean hasExternalStoragePrivateFile() { // Get path for the file on external storage. If external // storage is not currently mounted this will fail. File file = new File(getExternalFilesDir(null), DemoFile.jpg); if (file != null) { return file.exists(); } return false; } } In this example he copied a picture from the app, but me i want to copy the file data on /data/data.. ! how doing it ? Thank you :). On 30 mar, 14:05, Kostya Vasilyev kmans...@gmail.com wrote: 30.03.2011 22:00, Alaeddine Ghribi пишет: Ah okay i think that i understand the point now ! 1st link: how to copy two file. 2nd link: where to copy it. That's it ? That's right! -- Kostya Vasilyev --http://kmansoft.wordpress.com -- 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
[android-developers] Re: Import/Export data file
I thinked about this function, i just copy the file in a directory in the SDCARD and then to import just copy the file to /data/data/... But how doing it ? Thanks. On 30 mar, 17:08, Marcin Orlowski webnet.andr...@gmail.com wrote: On 30 March 2011 16:57, Alaeddine Ghribi alaeddineghr...@gmail.com wrote: Hi, I built an app that calculates fuel consumption, my data are well stored in a file, however, i often flash my phone and want to add the import-export feature on it ! How can i make this ? You keep your data set in file not DB? Then just copy it to SD card. Regards, Marcin Orlowski *Tray Agenda http://bit.ly/trayagenda* - keep you daily schedule handy... WebnetMobile on *Facebook http://webnetmobile.com/fb/* and *Twitterhttp://webnetmobile.com/twitter/ * -- 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
[android-developers] Re: Import/Export data file
Yes, i'm just using a file to store data, but how can i copy the file in data/data/. to the SDCARD? How doing it in JAVA/Android ? On 30 mar, 17:08, Marcin Orlowski webnet.andr...@gmail.com wrote: On 30 March 2011 16:57, Alaeddine Ghribi alaeddineghr...@gmail.com wrote: Hi, I built an app that calculates fuel consumption, my data are well stored in a file, however, i often flash my phone and want to add the import-export feature on it ! How can i make this ? You keep your data set in file not DB? Then just copy it to SD card. Regards, Marcin Orlowski *Tray Agenda http://bit.ly/trayagenda* - keep you daily schedule handy... WebnetMobile on *Facebook http://webnetmobile.com/fb/* and *Twitterhttp://webnetmobile.com/twitter/ * -- 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
Re: [android-developers] Re: Import/Export data file
On 30 March 2011 18:19, Alaeddine Ghribi alaeddineghr...@gmail.com wrote: Yes, i'm just using a file to store data, but how can i copy the file in data/data/. to the SDCARD? How doing it in JAVA/Android ? http://developer.android.com/reference/android/os/Environment.html#getExternalStorageDirectory%28%29 http://www.google.pl/search?q=how+to+copy+files+java Regards, Marcin Orlowski *Tray Agenda http://bit.ly/trayagenda* - keep you daily schedule handy... WebnetMobile on *Facebook http://webnetmobile.com/fb/* and *Twitterhttp://webnetmobile.com/twitter/ * -- 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
[android-developers] Re: Import/Export data file
Thank for your answer, and i know how to use io files. But i'm asking how to specify the location of the file in import and export operations ? On 30 mar, 17:22, Mark Murphy mmur...@commonsware.com wrote: On Wed, Mar 30, 2011 at 12:19 PM, Alaeddine Ghribi alaeddineghr...@gmail.com wrote: Yes, i'm just using a file to store data, but how can i copy the file in data/data/. to the SDCARD? How doing it in JAVA/Android ? Standard Java file I/O. If you are new to Java, I recommend spending some time learning Java outside of Android first. Here is a blog post with a list of Java topics that Android developers need to know before getting into Android: http://commonsware.com/blog/2010/08/02/java-good-parts-version.html -- Mark Murphy (a Commons Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9.2 Available! -- 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
Re: [android-developers] Re: Import/Export data file
On Wed, Mar 30, 2011 at 12:19 PM, Alaeddine Ghribi alaeddineghr...@gmail.com wrote: Yes, i'm just using a file to store data, but how can i copy the file in data/data/. to the SDCARD? How doing it in JAVA/Android ? Standard Java file I/O. If you are new to Java, I recommend spending some time learning Java outside of Android first. Here is a blog post with a list of Java topics that Android developers need to know before getting into Android: http://commonsware.com/blog/2010/08/02/java-good-parts-version.html -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9.2 Available! -- 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
[android-developers] Re: Import/Export data file
This one is perfect: http://www.roseindia.net/java/beginners/CopyFile.shtml I just don't know how to specify the location of the import/export operations, where to copy and where to past :\ ! Thank you for your help. On 30 mar, 17:26, Marcin Orlowski webnet.andr...@gmail.com wrote: On 30 March 2011 18:19, Alaeddine Ghribi alaeddineghr...@gmail.com wrote: Yes, i'm just using a file to store data, but how can i copy the file in data/data/. to the SDCARD? How doing it in JAVA/Android ? http://developer.android.com/reference/android/os/Environment.html#ge...http://www.google.pl/search?q=how+to+copy+files+java Regards, Marcin Orlowski *Tray Agenda http://bit.ly/trayagenda* - keep you daily schedule handy... WebnetMobile on *Facebook http://webnetmobile.com/fb/* and *Twitterhttp://webnetmobile.com/twitter/ * -- 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
[android-developers] Re: Import/Export data file
This one is perfect: http://www.roseindia.net/java/beginners/CopyFile.shtml I just don't know how to specify the location of the import/export operations, where to copy and where to past :\ ! Thank you for your help. On 30 mar, 17:26, Marcin Orlowski webnet.andr...@gmail.com wrote: On 30 March 2011 18:19, Alaeddine Ghribi alaeddineghr...@gmail.com wrote: Yes, i'm just using a file to store data, but how can i copy the file in data/data/. to the SDCARD? How doing it in JAVA/Android ? http://developer.android.com/reference/android/os/Environment.html#ge...http://www.google.pl/search?q=how+to+copy+files+java Regards, Marcin Orlowski *Tray Agenda http://bit.ly/trayagenda* - keep you daily schedule handy... WebnetMobile on *Facebook http://webnetmobile.com/fb/* and *Twitterhttp://webnetmobile.com/twitter/ * -- 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
Re: [android-developers] Re: Import/Export data file
30.03.2011 20:31, Alaeddine Ghribi пишет: This one is perfect: http://www.roseindia.net/java/beginners/CopyFile.shtml I just don't know how to specify the location of the import/export http://developer.android.com/guide/topics/data/data-storage.html#filesExternal -- Kostya operations, where to copy and where to past :\ ! Thank you for your help. On 30 mar, 17:26, Marcin Orlowskiwebnet.andr...@gmail.com wrote: On 30 March 2011 18:19, Alaeddine Ghribialaeddineghr...@gmail.com wrote: Yes, i'm just using a file to store data, but how can i copy the file in data/data/. to the SDCARD? How doing it in JAVA/Android ? http://developer.android.com/reference/android/os/Environment.html#ge...http://www.google.pl/search?q=how+to+copy+files+java Regards, Marcin Orlowski *Tray Agendahttp://bit.ly/trayagenda* - keep you daily schedule handy... WebnetMobile on *Facebookhttp://webnetmobile.com/fb/* and *Twitterhttp://webnetmobile.com/twitter/ * -- Kostya Vasilyev -- http://kmansoft.wordpress.com -- 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
[android-developers] Re: Import/Export data file
Always here M.Kostya ;), Anyway, this guide shows how to store the saved file in the SDCARD? With the choose of the storage location ? And the import location ? And no need to see this code? http://www.roseindia.net/java/beginners/CopyFile.shtml Thank you. On 30 mar, 17:49, Kostya Vasilyev kmans...@gmail.com wrote: 30.03.2011 20:31, Alaeddine Ghribi пишет: This one is perfect: http://www.roseindia.net/java/beginners/CopyFile.shtml I just don't know how to specify the location of the import/export http://developer.android.com/guide/topics/data/data-storage.html#file... -- Kostya operations, where to copy and where to past :\ ! Thank you for your help. On 30 mar, 17:26, Marcin Orlowskiwebnet.andr...@gmail.com wrote: On 30 March 2011 18:19, Alaeddine Ghribialaeddineghr...@gmail.com wrote: Yes, i'm just using a file to store data, but how can i copy the file in data/data/. to the SDCARD? How doing it in JAVA/Android ? http://developer.android.com/reference/android/os/Environment.html#ge... Regards, Marcin Orlowski *Tray Agendahttp://bit.ly/trayagenda* - keep you daily schedule handy... WebnetMobile on *Facebookhttp://webnetmobile.com/fb/* and *Twitterhttp://webnetmobile.com/twitter/ * -- Kostya Vasilyev --http://kmansoft.wordpress.com -- 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
Re: [android-developers] Re: Import/Export data file
The link you posted explains how to copy a file from one location to another. The link to developer.android.com explains where to copy the file to, as well as some other points. You just need to combine those two :) -- Kostya 30.03.2011 21:41, Alaeddine Ghribi пишет: Always here M.Kostya ;), Anyway, this guide shows how to store the saved file in the SDCARD? With the choose of the storage location ? And the import location ? And no need to see this code? http://www.roseindia.net/java/beginners/CopyFile.shtml Thank you. On 30 mar, 17:49, Kostya Vasilyevkmans...@gmail.com wrote: 30.03.2011 20:31, Alaeddine Ghribi пишет: This one is perfect: http://www.roseindia.net/java/beginners/CopyFile.shtml I just don't know how to specify the location of the import/export http://developer.android.com/guide/topics/data/data-storage.html#file... -- Kostya operations, where to copy and where to past :\ ! Thank you for your help. On 30 mar, 17:26, Marcin Orlowskiwebnet.andr...@gmail.comwrote: On 30 March 2011 18:19, Alaeddine Ghribialaeddineghr...@gmail.comwrote: Yes, i'm just using a file to store data, but how can i copy the file in data/data/. to the SDCARD? How doing it in JAVA/Android ? http://developer.android.com/reference/android/os/Environment.html#ge... Regards, Marcin Orlowski *Tray Agendahttp://bit.ly/trayagenda* - keep you daily schedule handy... WebnetMobile on *Facebookhttp://webnetmobile.com/fb/* and *Twitterhttp://webnetmobile.com/twitter/ * -- Kostya Vasilyev --http://kmansoft.wordpress.com -- Kostya Vasilyev -- http://kmansoft.wordpress.com -- 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
[android-developers] Re: Import/Export data file
...But what is the line that refers to the location of the saved file in the posted link(code) :\ ? I think that it just copy a file, but where saving it ? :\(confuse : ( ) Thank you. On 30 mar, 18:46, Kostya Vasilyev kmans...@gmail.com wrote: The link you posted explains how to copy a file from one location to another. The link to developer.android.com explains where to copy the file to, as well as some other points. You just need to combine those two :) -- Kostya 30.03.2011 21:41, Alaeddine Ghribi пишет: Always here M.Kostya ;), Anyway, this guide shows how to store the saved file in the SDCARD? With the choose of the storage location ? And the import location ? And no need to see this code?http://www.roseindia.net/java/beginners/CopyFile.shtml Thank you. On 30 mar, 17:49, Kostya Vasilyevkmans...@gmail.com wrote: 30.03.2011 20:31, Alaeddine Ghribi пишет: This one is perfect: http://www.roseindia.net/java/beginners/CopyFile.shtml I just don't know how to specify the location of the import/export http://developer.android.com/guide/topics/data/data-storage.html#file... -- Kostya operations, where to copy and where to past :\ ! Thank you for your help. On 30 mar, 17:26, Marcin Orlowskiwebnet.andr...@gmail.com wrote: On 30 March 2011 18:19, Alaeddine Ghribialaeddineghr...@gmail.com wrote: Yes, i'm just using a file to store data, but how can i copy the file in data/data/. to the SDCARD? How doing it in JAVA/Android ? http://developer.android.com/reference/android/os/Environment.html#ge... Regards, Marcin Orlowski *Tray Agendahttp://bit.ly/trayagenda* - keep you daily schedule handy... WebnetMobile on *Facebookhttp://webnetmobile.com/fb/* and *Twitterhttp://webnetmobile.com/twitter/ * -- Kostya Vasilyev --http://kmansoft.wordpress.com -- Kostya Vasilyev --http://kmansoft.wordpress.com -- 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
[android-developers] Re: Import/Export data file
Ah okay i think that i understand the point now ! 1st link: how to copy two file. 2nd link: where to copy it. That's it ? On 30 mar, 18:46, Kostya Vasilyev kmans...@gmail.com wrote: The link you posted explains how to copy a file from one location to another. The link to developer.android.com explains where to copy the file to, as well as some other points. You just need to combine those two :) -- Kostya 30.03.2011 21:41, Alaeddine Ghribi пишет: Always here M.Kostya ;), Anyway, this guide shows how to store the saved file in the SDCARD? With the choose of the storage location ? And the import location ? And no need to see this code?http://www.roseindia.net/java/beginners/CopyFile.shtml Thank you. On 30 mar, 17:49, Kostya Vasilyevkmans...@gmail.com wrote: 30.03.2011 20:31, Alaeddine Ghribi пишет: This one is perfect: http://www.roseindia.net/java/beginners/CopyFile.shtml I just don't know how to specify the location of the import/export http://developer.android.com/guide/topics/data/data-storage.html#file... -- Kostya operations, where to copy and where to past :\ ! Thank you for your help. On 30 mar, 17:26, Marcin Orlowskiwebnet.andr...@gmail.com wrote: On 30 March 2011 18:19, Alaeddine Ghribialaeddineghr...@gmail.com wrote: Yes, i'm just using a file to store data, but how can i copy the file in data/data/. to the SDCARD? How doing it in JAVA/Android ? http://developer.android.com/reference/android/os/Environment.html#ge... Regards, Marcin Orlowski *Tray Agendahttp://bit.ly/trayagenda* - keep you daily schedule handy... WebnetMobile on *Facebookhttp://webnetmobile.com/fb/* and *Twitterhttp://webnetmobile.com/twitter/ * -- Kostya Vasilyev --http://kmansoft.wordpress.com -- Kostya Vasilyev --http://kmansoft.wordpress.com -- 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
Re: [android-developers] Re: Import/Export data file
30.03.2011 22:00, Alaeddine Ghribi пишет: Ah okay i think that i understand the point now ! 1st link: how to copy two file. 2nd link: where to copy it. That's it ? That's right! -- Kostya Vasilyev -- http://kmansoft.wordpress.com -- 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