0

I'm sorry, i didn't have any code for the moment but i need help.

My android application : In a string-array, i have a lot of sentences (declared on a .xml file).

In my android application i want this : User can create her sentences (illimitate) and stock it in xml file.

How can i make a function who add somes sentences to a .xml file.

If it's not possible, how can i make it

Exemple : In my app, i have :

    <string-array name="MyStringArra1">
        <item>My Sentence 1</item>
        <item>My Sentence 2</item>
</string-array>

And if user add : Sentence 3, i want put it in this file.

4
  • So you want to modify your App resorces? Commented Jul 30, 2017 at 15:41
  • Yes. I want add elements to "MyStringArray_user" when he add sentences Commented Jul 30, 2017 at 15:43
  • 3
    @AlexFrasure If i'm guessing correctly you wanna add/store extra sentences in a resource file, for each user / install individually? If so, there's a problem. The files under resources are meant to be read-only. You can however try other datastores in the Android ecosystem. developer.android.com/training/basics/data-storage/files.html would be a great place to start. Just read another file from storage in onStart etc and in onStop write all the new lines to that same file. Commented Jul 30, 2017 at 15:43
  • @MrKickkiller Ok, thank you for this documentation. Commented Jul 30, 2017 at 15:45

1 Answer 1

1

You cannot modify resource files from your Android application as they are compiled into your app, and therefore don't even exist on your device. If you want your user to be able to insert/edit/remove strings from a list, you must use a database or Shared Preferences.

The following link guides you into creating a ToDo list application, which is basically a list of strings. Starting Android Development, Creating a Todo App

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.