Android Question I can't find anywhere the SAF library to write mi db in Documents, can anyone help?

IndigoMex

Member
I can't find anywhere the SAF library to write mi db in Documents, can anyone help? I tried everything I know with examples and did'n work, I need to copy and upddate a SQLite db and syn with windows
 

aeric

Expert
Licensed User
Longtime User
How about backup the sqlite db and save in a location that can be access by File Manager?

If you just only want to sync your data to PC or server, there are many other ways.
You can use jRDC2, use OkHttputils2 to call REST API or web services, CloudKVS to name a few.
 
  • Like
Reactions: zed
Upvote 0

IndigoMex

Member
Hi, thank you for your answer, I have an app that needs to update a SQLite database, everything works just fine, when I finished update the DB I need it to copy from a Windows PC and process it, and when its done send it back to Android. I completed yesterday using a SD card but the lenght of the file it's 0. I need to make the copy back and forward from a file location accesible with a Windows PC. all the solutions pointingto SAF Library but I connot find any working example of writing files to Documents or Download. Any help will be appreciated.
 
Upvote 1

aeric

Expert
Licensed User
Longtime User
I connot find any working example of writing files to Documents or Download.
The example I shared is working.
You can choose the Download folder to store your sqlite in Android.
Please try first and tell us why it is not working.
 
Upvote 0

IndigoMex

Member
It works just fine !!! now I need to figure how to write back the SQLite db to DirInternal.. the best solution for my app it will be place the DB in some folder like Documents or Download in order to read it from my app, that will be much easer to mantain since I have acces from windows, process the DB and send it back to Android.

There is some method to do that?

sql.Initialize(dbPath, dbFileName, True)

dbpath as Documents or Download?

Thanks for all the help
 
Upvote 0

IndigoMex

Member
Well, to copy my db from a Directory that I created on /Android?Data/xxxxxx to DirInternal was to easy
Your app must only read the sqlite database from File.DirInternal

Did you try the Restore function in post #4?

Hi, thank you so much for all the help, I just finished the app and works great, it save the file to Download, so I used:
  • MediaStore.Downloads.EXTERNAL_CONTENT_URI
The only problem it's that function don't support Display_Name, so the final file its just number without extension. Copied the file, renamed as MyDb.db and open just great on Windows with all the updates.

Thank you again for all the good work here !!!
 
Upvote 0
Top