Question

i am new in android. i want to make a program that in it i will write some text to some files and read them another time.

i am confused abut how i can do it.

i use at first from below code for reading:

InputStreamReader in = new InputStreamReader(ctx.openFileInput("syncConfig.ini"));

it not works on LG devices between Samsung, LG and Sony that i am testing on them.

i think that at some other devices may be not works.

then i use below code :

String sdcard = Environment.getExternalStorageDirectory().getPath();
FileInputStream in = new FileInputStream(new File(sdcard+"/yekana_data/syncConfig.ini"));

the directory yekana_data are exists.

then i think that some devices may have no sdcard or not mounted or device is connected to PC or so on, at this time my program not works or will be wrong later.

i want to write to a place that all devices support it and in all times is accessible for my program.

how i can solve it?

Was it helpful?

Solution

You can learn more about saving files on the android developer site.

http://developer.android.com/training/basics/data-storage/files.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top