Reputation: 12018
I want to create/write new files on the device. I am able to create file on sd card of the android device.
But in case if device is not having sd card then where should i create file which can be accessible from the ddms.
I tried to create it in /data/data/com.abc.app/files/ directory, But i don't have permissions to access this directory from the ddms to save the file on pc.
Which is the best location create new file on the device which can be access from ddms and application.
Upvotes: 0
Views: 1601
Reputation: 12304
Try use cache dir local and external.
Here is a part of my code
File dir = context.getExternalCacheDir() != null ?
context.getExternalCacheDir() : context.getCacheDir();
File file = new File(dir, ".cachefile");//hidden
if (file.exists())
file.delete();
FileOutputStream out = new FileOutputStream(file);
//..
out.flush();
out.close();
Don't forget to have permissions read/write;
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Upvotes: 1
Reputation: 157447
you have the permission to write/read in/from that folder through your applicatin. You have to use the pair openFileInput
/openFileOutput
here the doc per openFileInput/openFileOutput
Upvotes: 0