Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to save back into a file in assets folder

I understand I can open a file in assets folder like this.

InputStream is = ((Activity) mView).getAssets().open("some.txt");

But what should I do to save back to the same file? I mean how do I get OutputStream of the same file?

like image 878
Tae-Sung Shin Avatar asked Dec 05 '11 05:12

Tae-Sung Shin


People also ask

How do I add files to Assets folder?

Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml. Step 3 – Create a new Assets folder and write a new text file in it.

How do I create an asset file?

Standard users who are members of the Asset Library can also create asset files. From Files home, go to Libraries | Asset Library. Click Upload Asset File. The file selector opens to let you upload a new file or select an existing file to make into an asset.

What are Assets folder?

The Assets folder is where you should save or copy files that you want to use in your project. The contents of the Project Window in Unity shows the items in your Assets folder.

What should I store in Assets folder?

In Android one can store the raw asset file like JSON, Text, mp3, HTML, pdf, etc in two possible locations: assets. res/raw folder.


1 Answers

As per my knowledge you can't because /asset directory is not writeable, So you can't make any changes on file which are in /asset directory, Its because Android .apk file is only readable.

For more info look at this discussion Writing to file Assets folder And this SO question How to write files to assets folder or raw folder in android?

like image 72
user370305 Avatar answered Sep 21 '22 07:09

user370305