android saving to SD card

纵然是瞬间 提交于 2019-12-05 20:21:51
MByD

You declared your method as public String which means it has to return a String object from the function (using the return keyword) if you don't want the function to return anything, use the void keyword instead of String.

The second error means that somewhere you called SDSave method using a String as arguments (SDSave(extStorageDirectory + "/qr11.PNG");) while this function takes no arguments (public String SDSave( )).

I suggest you would try a Java tutorial or two, since those rules are the very basics of Java (and actually, of many programing languages).

Your asking your method to return a String

 public String SDSave()

you would need the line, at the end of your code:

return "someString"; 

If you don't want to return a string use:

public void SDSave()

The second error, your trying to pass a String into your method, but your method doesn't take any variables. You would need:

public void SDSave(String myInputStringVariable)

Yes these are Java basic's , so I'd go read up on Java and OO, also check this out:

Top Ten Errors Java Programmers Make

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

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

Hope it will help u.

public void SDSave(String file){
    File f=new File(file);
    ...
}

Hey You can use my sample code shared on Github repo link This sample contains :

  1. Download image from web.
  2. You can also share this image.
  3. You can save this image on Sd card.
  4. Image Caching is also there
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!