android - Create a file on different mobile phones in Qt -


I want to create cross-platform applications. It is not related to a particular tablet or smartphone, it is considered to be run on any device. However, I want to make a file on the device. The problem is that I do not know where to save it. Because it is a cross-platform, I can not specify a path for that file.

QT provides excellent class. Direct from Docs:

The QStandardPaths class provides methods to reach the standard path. This category contains functions to query standard location on the local file system, such as for user-specific directories or system-wide configuration directories.

Specifically you should use the static method:

  QStringList QStandardPaths :: standard layout (standard location type)  

A common use can be defined for the home directory as the following:

QString basePath = QStandardPaths :: Standard Layout (QStandardPaths :: HomeLocation) [0]

Note that I returned stringlist for first entry, if it is empty then without check. It's safe because the returned object never is empty for the home location! This is not always the case, but there are quite a lot about the docs and also what places have returned to each specific platform. Also note that, if not specified separately (see the document again for specific cases), the first entry returned in the string list is always writable .

Em> supported This version was not correct for minors compared to 5.2 (for example, close but for more information about more about the Qt release cycle about iOS code, q standandpath support).

Finally, a consultation if you are interested in the sharing file between Android / iOS device and have a PC via USB, then a good location option QStandardPaths :: DownloadLocation may be . Keep in mind that iOS should be defined in additional policies for file sharing, i.e. the UIFileSharingEnabled key should be set in your app's information plist.


Comments