File permissions

56 views
Skip to first unread message

Ole-Johan

unread,
Nov 3, 2010, 8:49:57 AM11/3/10
to android-qt
Hi.

I am trying to create a file and write to it, but get "permission
denied" when opening a file with write permissions.

Reading works:
QFile file("/sdcard/temp/test.txt");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) ...

But opening the same file or trying to create a new file in the same
directory with write access doesn't work. I have tried a lot of
different directories.

I first encountered it when trying to open and update a sqlite db,
which resulted in an errormessage saying the database was write
protected.

Any hints?

Best regards, Ole-Johan

Sergey A. Galin

unread,
Nov 3, 2010, 9:40:02 AM11/3/10
to android-qt
Hi Ole-Johan,

Check your AndroidMainfest.xml for permission tags. Here are some
useful tags (all these permission requirements will be shown to user
when installing apk, so don't use these you don't actually need_:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
...
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /
>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /
>
<uses-permission android:name="android.permission.WAKE_LOCK" />
</manifest>.

--
Regards,
Sergey

Ole-Johan

unread,
Nov 3, 2010, 11:00:24 AM11/3/10
to android-qt
Perfect!! Works like a charm! :) Thanks!!
Reply all
Reply to author
Forward
0 new messages