0

There is a file strings.xml:

<?xml version="1.0" encoding="utf-8"?>
<string name="param">0</string>

need to read a variable named "param" and change it to another int variable
or read and write to a file located in this APK, for example /assets/config.txt?

2 Answers2

0

Don't try to modify the APK.

You should consider using other "persistent storage" options for your Android application ... you don't really want to be modifying the contents of your APK on the device. Shared Preferences, External Storage or SQLite Databases are among the options you have. You may want to read more documentation about these options on the Android developer area here

ErstwhileIII
  • 4,829
  • 2
  • 23
  • 37
  • I need to edit the APK that when transferring it to another device, the settings have already been put into this apk. – Artem Pimushkin Aug 24 '14 at 18:26
  • I am not sure I understand your "clarification". Are you talking about what you need to do to publish a new version of an "APK" file? Otherwise, why aren't you using a "publish" / "distribute" model for your application? – ErstwhileIII Aug 24 '14 at 18:30
  • I will try to explain easier: if I somehow changed the application on my device and transferred it to you, then you it will be with the same changes. – Artem Pimushkin Aug 24 '14 at 18:49
  • You do not want to use that vector as a way maintain and distribute your application. (Well, you may want to, but it is fraught with security issues.) – ErstwhileIII Aug 24 '14 at 18:55
  • I need to do it as a defense against the free distribution of my application, because android lvl does not fit. – Artem Pimushkin Aug 24 '14 at 19:01
  • You are NOT planning on distributing your application using Google Play !?? – ErstwhileIII Aug 24 '14 at 19:03
  • No, I am plainning to distributing my paid application on Google Play, but it not protect against transfer the app to another device (for example bluetooth). – Artem Pimushkin Aug 24 '14 at 19:13
0

You cannot write/modify file in assets folder runtime. Please check How to write files to assets folder or raw folder in android?

Community
  • 1
  • 1
Anirban Pal
  • 529
  • 4
  • 10