Security Exception while reading preferences

News, information, contests and special event announcements from members of the anddev.org community.

Security Exception while reading preferences

Postby swapnil » Thu Sep 23, 2010 10:30 am

Hi all,
If i create manually preference xml file and try to push in device i can able to read the file contains.

But same thing if i create prefrence xml file from code and trying to read it from code it throws following warning and value read got wrong.
WARN/ApplicationContext(5323): Attempt to read preferences file /data/data/com.xyz/shared_prefs/Custom.xml without permission .

For writing the code is,
SharedPreferences sharedCustom = this.getSharedPreferences("Custom", Context.MODE_WORLD_WRITEABLE);
SharedPreferences.Editor editor = sharedCustom.edit();
editor.putInt("storedInt", 5); // value to store
editor.commit();
For reading them,
con = createPackageContext("com.hcl",
Context.CONTEXT_IGNORE_SECURITY|Context.CONTEXT_INCLUDE_CODE | Context.MODE_WORLD_WRITEABLE);
SharedPreferences sPreferences=con.getSharedPreferences("Custom", Context.MODE_WORLD_WRITEABLE);
int value = sPreferences.getInt("storedInt",0);

Regards,
Swapnil
swapnil
Freshman
Freshman
 
Posts: 9
Joined: Thu Sep 09, 2010 11:04 am

Top

Return to Open News

Who is online

Users browsing this forum: No registered users and 3 guests