Android .txt resource file editing in Qt
-
I may be wrong but as far as I know on Android you cannot write in the directory where your app is installed (for security reasons). The qrc file is part of your application, so I guess it will not work this way. You should use a directory where your app has write access.
-
Check this one on Android:
QString QStandardPaths::writableLocation(StandardLocation type) Call it like this: QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
More here: http://doc.qt.io/qt-5/qstandardpaths.html
-
Thank you a LOT! Especially for Standard Paths. It works :) I've got last small question. I've noticed that I understand file operation modes wrong. Writing in append mode seems easy. As a ReadOnly mode, I understand the mode in which you start reading the file from the beggining. But now I found that WriteOnly mode erases all file and starts writing from the beginning! Is that right? I thought that WriteOnly opens the file with pointer pointing the beginning of file, and so I thought that writing in that mode allows me to replace previously written characters. I want to find the mode that allows me to change the number at the beginning without writing whole file again...
-
Sorry that I've got even more questions :D
Can I declare structures with QStrings and then resize them inside that structure? Does structure also resize itself then?
Am I correct that I don't have to resize the QString when I declare:
QString valuvalue = somekindofcharorstring;
?
It changes its size automatically, am I right? -
hi,i offer, you can use xml or json for saving your data
Data storage -
I think it can be much easier with LocalStorage , it can be done entirely from QML:
http://qmlbook.github.io/en/ch12/index.html#local-storage-sqlI think this is the simpler solution to establish saving ability for an app, but you can't access the stored information from outside your app.
-
Thank you a LOT! Especially for Standard Paths. It works :) I've got last small question. I've noticed that I understand file operation modes wrong. Writing in append mode seems easy. As a ReadOnly mode, I understand the mode in which you start reading the file from the beggining. But now I found that WriteOnly mode erases all file and starts writing from the beginning! Is that right? I thought that WriteOnly opens the file with pointer pointing the beginning of file, and so I thought that writing in that mode allows me to replace previously written characters. I want to find the mode that allows me to change the number at the beginning without writing whole file again...
@monster Use
QIODevice::WriteOnly | QIODevice::Append
Then the file should not be overwritten.
You can declare structures containing strings. The size of the struct does not depend on the size of stored strings, because internally QString stores the actual string on the heap and just points to it. On my machine sizeof(StrStruct) is 16 (StrStruct contains two QString members). So it is 2 * sizeof(void*).