android - Write a private access file to another app's files directory -


the 2 apps have same shareduserid. when use code in app1

context.openfileoutput("/data/data/org.me.app2/files/shared-data.dat", mode_private) 

i exception telling me file contains path separator.

i trying write file app1 app2's storage. (i of course need make sure app2's files directory exists first)

ideally, write user specific directory instead of app specific directory, not know if can done

first of all, never use full path internal storage /data/data. let operating system give path (for example, via context.getfilesdir() or environment.getexternalstoragestate()). don't make assumption on data is.

secondly - doing that! unlike file, context.openfileoutput prepends /data/data/[package] path, don't need specify that. specify file name.

if feel it's safe , necessary, , if both apps share same user id using android:shareduserid in manifest, can context of other app using context.createpackagecontext() , use context_restricted, use openfileoutput file name.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -