मैं नीचे कोड के साथ एसडीकार्ड में एक फ़ाइल लिखने की कोशिश कर रहा हूं (अनुमति android.permission.WRITE_EXTERNAL_STORAGE
पहले से ही manifest.xml में सेट है)। nmea_file.createNewFile();
के निष्पादन पर यह Permission Denied
के साथ अपवाद फेंकता है।एंड्रॉइड एसडी कार्ड लेखन, अनुमति अस्वीकार
कोई अनुमान यह क्यों हो रहा है?
if(!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED))
{
Log.d(TAG, "Sdcard was not mounted !!");
}
else
{
File nmea_file;
File root = Environment.getExternalStorageDirectory();
FileWriter nmea_writer = null;
try {
nmea_file = new File(root,"NMEA.txt");
if(!nmea_file.exists()) {
Log.w(TAG, "File Doesn't Exists!");
nmea_file.createNewFile();
}
nmea_writer = new FileWriter(nmea_file);
nmea_writer.append(nmea);
nmea_writer.flush();
}
catch (IOException e)
{
Log.w(TAG, "Unable to write", e);
}
finally
{
if (nmea_writer != null)
{
try
{
nmea_writer.close();
}
catch (IOException e)
{
Log.w(TAG, "Exception closing file", e);
}
}
}
}
अपना लॉककैट – Falmarri
पोस्ट करें क्या आप सिस्टम में sharedUerId का उपयोग कर रहे हैं? –