开发者

Android /data/data/mypackage/img

开发者 https://www.devze.com 2023-04-04 11:44 出处:网络
I have saved same image i开发者_开发问答nto /data/data/mypackage/img/ and now I want show this full screen, I had try with ACTION_VIEW for show with android standard program but it not read from /data

I have saved same image i开发者_开发问答nto /data/data/mypackage/img/ and now I want show this full screen, I had try with ACTION_VIEW for show with android standard program but it not read from /data/data/.. How can I do ?


The 'android standard program' you are launching is not able to access /data/data/mypackage, and thus cannot load the images you are saving in there

Try saving your images in a directory on the SD card instead:

File sdDir = new File(Enviroment.getExternalStorageDirectory(), "mydirname");

If your device doesn't have an SD card then you will need to create a world readable subdirectory inside your package dir, and then create a world readable file within it (Android 2.3+)

File filesysDir = getDir("mydirname", MODE_WORLD_READABLE);
File file = new File(sdDir, "myfile.txt");
file.setReadable(true, false);
FileOutputStream fos = new FileOutputStream(file);
String txt = "hello world";
fos.write(txt.getBytes());
fos.close();

Or if you are on earlier versions of Android it looks like you don't get much choice in the directory name. The following code will create a world readable file in the data/data/mypackagename/files/ directory

FileOutputStream fos = openFileOutput("myfile2.txt", MODE_WORLD_READABLE);
String txt = "hello world";
fos.write(txt.getBytes());
fos.close();
0

精彩评论

暂无评论...
验证码 换一张
取 消