I want to create a file on an SD card and then save the CSV file in it.
From surfing around, I noticed that there seem to be two ways around this:
http://developer.android.com/guide/topics/data/data-storage.html#filesExternal
If you use API level 8 or more, use getExternalFilesDir () to open a file representing the external storage directory in which you should save your files. This method takes a type parameter that indicates the type of subdirectory you want, such as DIRECTORY_MUSIC and DIRECTORY_RINGTONES (going from null to get the root of your application file).
If you are using API level 7 or lower, use getExternalStorageDirectory () to open the file representing the root of the external storage. Then you should write your details in the following directory:
/ Android / data // files /
And http://www.anddev.org/working_with_files-t115.html :
FileWriter f = new FileWriter("/sdcard/download/possible.txt");
Which way to use? If the first, how can I write an application for compatibility with the API level <= 7 and> = 8? Is there any good tutorial for this, first of all?
source
share