I am able to find the right way to write a file in a subdirectory of the Android data I have tried over the last few days folder. The majority of the answers I found were unclear or did not solve the problem in the correct and working way, so I decided to finally ask. I am giving a user the possibility of backing up my data on my server by basically uploading a database to a server via a PHP script. Database
'/ data / data / com.package / database / data.db is located in'
The problem is that when a user wants To reload a back up database, download the application file and then write it (overwrite the old one) / / into the database / data.db file, and then reload. I have managed to do everything, as far as I have to download the downloaded file because FileOutputStream tells an invalid argument exception that I can not use path separator in the way. I understand that FileOutputStream can only write to the first level of the data folder and not for sub-directories. How can this be done? If this can not be done, is there a way to set the default database path to the first level of the 'data' directory to solve this problem? If this is a completely wrong approach that I want to achieve, I am open for criticism, but it will still be good to get the answer, only for the future. ) {If (valid Krensserrspons (FeedkResult)) Try directory {// Copy database {FileOutputStream fos = ctx.openFileOutput (ctx.getDatabasePath (DataDatabaseHelper.DBNAME) .getAbsolutePath (), Context.MODE_PRIVATE); Fos.write (feed.DownloadedBytes, 0, feed.DownloadedBytes.length); Fos.close (); } Hold (IOException e) {e.printStackTrace (); }} And Toast Mektekst (Sitiaks, Sitiakskjetrisors (). GetString (r. Stringknofilsonsrvr), toast. Elananjiacaiacoarti). Show (); }
Thanks in advance.
How can
To write a file in the standard location for the database for your app.
Regardless of your path separator issue,
database /
directory is not
No comments:
Post a Comment