Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

copying file back to assets folder in android



  • my android application is having one default database file in asset-folder.whenever i open my android app ,i will copy this database file to a writable location (iam using QFile.copy() for copying file and QStandardpath to identify writable location) .then iam making some changes to this database file.at the end whenever i close the android app i must copy back this database file (i hope this is the right way to do)to assets folder.this is where iam failing,for some reason iam not able to copy back database file back to assets folder in android.(iam using Qfile.copy() api).Qfile.copy() will fail if the file which iam copying is already exists in the destination location, so i tried deleting the database file in asset folder but there also it is failing.then i thought this might be becauase of permission issue then i tried changing the permission of database file (for this i had used QFile::setPermissions) in asset folder but there also iam failing.
    is it because of asset folder ? how one can change file permission which are in asset folder ?is it possible to copy/remove files which are in asset folder?
    what way i can solve this problem? please let me know!!


  • Lifetime Qt Champion

    Hi,

    AFAIK, the assets are read-only resources so you can't copy back to it.


  • Qt Champions 2019

    @divaindie Why do you want to copy the db back to assets folder?



  • @SGaist said in copying file back to assets folder in android:

    Hi all ,thanks for your answers.yesterday i found out that there is no need to copy back database file to asset folder.earlier i assumed that if i unninstall the app "appdatalocation-folder" still exists on android file system,but the truth is that this location is deleted whenever i uninstall the app.so i do not need to copy back db file to assets folder !!!
    thanks!!


Log in to reply