Siddiqui
Siddiqui

Reputation: 7840

Pushing File into Android Device

I have developed an application which read text file. In Emulator I have push the file in \Data\Data\PackageName\File.txt and its working fine. But when I try to push file in Device its generate the error Read Only File System. I have try to remount directory as writable but the same error. Please help me how can I push file into device.

Upvotes: 1

Views: 1071

Answers (2)

ingsaurabh
ingsaurabh

Reputation: 15269

The folder you are trying is locked on non-rooted phones i.e no write permission and I guess the device you are trying on is not a rooted one. since emulator is sort of developer device which is said to be rooted that's why you can push file to that location.

So depending on your requirement you have to either use Assest folder or File system storage

Update: How to use assest folder

Resources r = getResources();
AssetManager assetManager = r.getAssets();
InputStream in = assetManager.open(filename);

Upvotes: 2

Paresh Mayani
Paresh Mayani

Reputation: 128428

In practice, we can push such file in assets folder. Assets folder is there for you to put such raw files to be used inside the application.

Upvotes: 1

Related Questions