图片保存~~~

simSunny 2011-08-03 09:52:52
各位大神,我想把修改的图片保存在sdcard中,用文件保存,运行是没有报错,但是不能在sdcard不能生成新的文件,我也改了权限了,这是我的代码,您能帮我看下哪错了么,谢了哈~~~
上代码
File myPictureFile = new File("/sdcard/newpicture.jpg");
try{
BufferedOutputStream bos = new BufferedOutputStream (new FileOutputStream(myPictureFile));

bitmap.compress(Bitmap.CompressFormat.JPEG, 100,bos);
bos.flush();
bos.close();

}catch(Exception e){
Log.w(TAG,e);
}
...全文
83 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
simSunny 2011-08-03
  • 打赏
  • 举报
回复
恩,谢谢大家了,搞好了哈~~貌似是权限的问题~~~
qiying1988 2011-08-03
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 c_simple 的回复:]
引用 9 楼 qiying1988 的回复:

adb shell
ls -l
看看sdcard 有读写权限吗?

不好意思的,这个是在哪看的啊?
[/Quote]

开始->cmd
----華----飛---- 2011-08-03
  • 打赏
  • 举报
回复
File myfile = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "newpicture.jpg") 你这样试试
simSunny 2011-08-03
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 qiying1988 的回复:]

adb shell
ls -l
看看sdcard 有读写权限吗?
[/Quote]
不好意思的,这个是在哪看的啊?
qiying1988 2011-08-03
  • 打赏
  • 举报
回复
adb shell
ls -l
看看sdcard 有读写权限吗?
simSunny 2011-08-03
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 zhenght19871029 的回复:]

你保存的地址好像只能读,不能写吧!换个能够写的文件夹
[/Quote]
不明白的 ~~换个能够写的文件夹,我把权限都改成可写的了,你说的是这个意思么
fontlose 2011-08-03
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 c_simple 的回复:]
引用 1 楼 fontlose 的回复:

要看logcat..

要看logcat..
这个我怎么看的~新手见谅的哈
[/Quote]

Windows-> Show View->Android->LogCat





simSunny 2011-08-03
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 fyan1900 的回复:]

路径对么?
[/Quote]
路径是你自己建立文件夹的时候自动生成的么,应该没问题
----華----飛---- 2011-08-03
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 c_simple 的回复:]

引用 1 楼 fontlose 的回复:

要看logcat..

要看logcat..
这个我怎么看的~新手见谅的哈
[/Quote]
window-->show view-->other..-->Android-->LogCat
zhenght19871029 2011-08-03
  • 打赏
  • 举报
回复
你保存的地址好像只能读,不能写吧!换个能够写的文件夹
----華----飛---- 2011-08-03
  • 打赏
  • 举报
回复
路径对么?
simSunny 2011-08-03
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 fontlose 的回复:]

要看logcat..
[/Quote]
要看logcat..
这个我怎么看的~新手见谅的哈
fontlose 2011-08-03
  • 打赏
  • 举报
回复
要看logcat..

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧