开发者

What permission am missing?

开发者 https://www.devze.com 2023-04-08 13:37 出处:网络
I\'m taking sms backup using this public void smsbackup() throws IOException { InputStream in = new FileInputStream(\"/data/data/com.android.providers.telephony/databases/mmssms.db\");

I'm taking sms backup using this

public void smsbackup() throws IOException
    {
        InputStream in = new FileInputStream("/data/data/com.android.providers.telephony/databases/mmssms.db");

        File dir = new File("/mnt/sdcard/bcfile");
        dir.mkdirs();

        OutputStream output = new FileOutputStream("/data/data/com.android.app/files/");

        byte[] buffer = new byte[1024];
        int length;
        while ((length = in.read(buffer))>0) 
        {
            output.write(buffer, 0, length);
        }
        output.flush();
        output.close();
        in.close();
    开发者_如何学JAVA}

It throws an exception like permission denied I don't know what permission will i give. Anyone tell me? Thanks in Advance.


You will need

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

because of

File dir = new File("/mnt/sdcard/bcfile");

I wonder if you can ever access: /data/data/com.android.providers.telephony/databases/mmssms.db


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

you have to add this permission since you are trying to write files to SDcard. hope this helps


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

You also need the permission of reading inbox messages.

Hope it will help you

0

精彩评论

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

关注公众号