What permission am missing?
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
精彩评论