机器人节约到SD卡 [英] android saving to SD card

查看:153
本文介绍了机器人节约到SD卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

喜所有我有一个小问题。

我有这个code,将图像保存到SD卡

 公共字符串SDSave(){//观为arg0
                // TODO自动生成方法存根
                的OutputStream outStream = NULL;
                档案文件=新的文件(extStorageDirectory,AdName +.PNG);
                尝试{
                    outStream =新的FileOutputStream(文件);
                    bm.com preSS(Bitmap.Com pressFormat.PNG,100,outStream);
                    outStream.flush();
                    outStream.close();                    Toast.makeText(WhereAmI.this,拯救,Toast.LENGTH_LONG).show();                }赶上(FileNotFoundException异常五){
                    // TODO自动生成catch块
                    e.printStackTrace();
                    Toast.makeText(WhereAmI.this,e.toString(),Toast.LENGTH_LONG).show();
                }赶上(IOException异常五){
                    // TODO自动生成catch块
                    e.printStackTrace();
                    Toast.makeText(WhereAmI.this,e.toString(),Toast.LENGTH_LONG).show();
                }            }

和IM这样从另一个梅索德叫它

 字符串sdSave = SDSave(extStorageDirectory +/qr11.PNG);

和IM显示2个错误,首先是在方法在公共字符串SDSave()和它说:

 此方法必须返回一个String类型的结果

和第二个是在字符串sdSave = SDSave(extStorageDirectory +/qr11.PNG); 和它说:

 的方法SDSave()在类型WHEREAMI不适用的参数(字符串)

一些帮助,请就如何解决它......

感谢您


解决方案

试试这个:
在manifest文件中写入有关用户permittion .....

 <使用许可权的android:NAME =android.permission.WRITE_EXTERNAL_STORAG​​E/>

希望这将帮助ü。

hi to all i have a small problem

i have this code to save an image to an SD card

public String SDSave( ) { //View arg0
                // TODO Auto-generated method stub
                OutputStream outStream = null;
                File file = new File( extStorageDirectory , AdName + ".PNG");
                try {
                    outStream = new FileOutputStream(file);
                    bm.compress(Bitmap.CompressFormat.PNG, 100, outStream);
                    outStream.flush();
                    outStream.close();

                    Toast.makeText(WhereAmI.this, "Saved", Toast.LENGTH_LONG).show();

                } catch (FileNotFoundException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    Toast.makeText(WhereAmI.this, e.toString(), Toast.LENGTH_LONG).show();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    Toast.makeText(WhereAmI.this, e.toString(), Toast.LENGTH_LONG).show();
                }

            }

and im calling it from another methode like this:

String sdSave = SDSave(extStorageDirectory + "/qr11.PNG");

and im showing 2 errors the first is at the method at public String SDSave( ) and it says:

This method must return a result of type String

and the second is at String sdSave = SDSave(extStorageDirectory + "/qr11.PNG"); and it says:

The method SDSave() in the type WhereAmI is not applicable for the arguments (String)

some help please on how to fix it.....

thank you

解决方案

try this: Write in manifest file about user permittion.....

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Hope it will help u.

这篇关于机器人节约到SD卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆