Android Question Edit Shared_Prefs manually

Air

Member
Licensed User
Longtime User
Strange behavior when manually changing the settings with a texteditor.

If the File

/data/data/com.my.app/shared_prefs/myApp_preferences.xml


is changed by an external program (like a texteditor), it is no longer accepted by myAPP.

Settings in the shared_prefs file are no longer read by myAPP and new settings are no longer saved.

The only Solutuion is to delete the file
/data/data/com.my.app/shared_prefs/myApp_preferences.xml

Is this behavior normal?
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
Can you post examples of the pre & post edited files?

- Colin.
 
Upvote 0

Air

Member
Licensed User
Longtime User
Can you post examples of the pre & post edited files?

- Colin.

Can not send a file, as I am about 2 weeks on the road (Trucker).

I can tell you the exact facts:

Test Phone 1:
Android 4.3 with root

  • Start myAPP
  • change the settings
  • close myAPP
  • settings saved.

Load myAPP_preferences.xml with text editor, change a setting (True to False), save file with text editor.

Load myAPP, settings can be read, changed and saved.


Test Phone 2:

Android 6.01 with root

  • Start myAPP
  • change the settings
  • close myAPP
  • settings saved
Load myAPP_preferences.xml with text editor, change a setting (True to False), save file with text editor.

  • Load myAPP
  • settings are not read
  • settings can be changed
  • close myAPP
  • settings are not saved

An Error was comming up, but i cant tell you exactly what it was.
Error: EACCES: permission denied, open '/data/data/myApp/shared_prefs/myAPP_preferences.xml'

The strange Thing is, that myAPP can not delete the prefsfile itself.
(There is a Function in myAPP to delete the Settingsfile and build a new file with Defaultsettings)

Perhaps it has something to do with the new permissions since Android 6.

Anyway, I can not do anything in the next 2 weeks because I'm on the road through Europe.


Air
 
Upvote 0

fixit30

Active Member
Licensed User
Longtime User
Sounds like you need to implement runtime permissions, or change your TargetSDK version to 19.
 
Upvote 0

Air

Member
Licensed User
Longtime User
If no other App (Texteditor) changes the prefs-file, there is no problem with myAPP (This is also normally the case). Everything works fine.

This behavoiur only comes up, if the file was changed by another APP.

I just came across this phenomenon by chance and just wanted to know if it was normal.
 
Upvote 0
Top