![]() I do not know if you are using my suggested replacement code or your original code. That is one of the reasons why I recommend not hard-coding paths, but instead using methods like context.getExternalFilesDir(null).Īt February 3, 2021, 6:34pm, AlanHaden replied:Īs you can see, its actually in the directory.Īt February 3, 2021, 6:35pm, AlanHaden replied:Īlthough it still isn’t being accessed by the app.Īt February 3, 2021, 6:52pm, mmurphy replied: For example, perhaps you changed it somewhere along the line and still kept trying to use the old directory. One possibility is that .haden.bestmobile is not your application ID. For example, if you are crashing or are seeing your log messages in Logcat, that would be useful to know.Īt February 3, 2021, 6:12pm, AlanHaden replied: I/System.out: Can't find currentDBPathĪt February 3, 2021, 6:25pm, mmurphy replied: If it does not work, reply on this thread with as much specifics as possible as to what your symptoms are. ![]() ![]() Be consistent between your import and export code - other than flipping where you are copying from and where you are copying to, your code should be identicalīeyond that, though, these revised methods should copy the files between the same two locations as before.Never hardcode absolute filesystem paths - always use a method on Context or Environment to derive them (and, in your case, you only need Context).You really really really really really need your database to be closed when doing import and export operations like this.…and copyFileOut() to something like: public boolean copyFileOut(Context context) String backupDBPath = "BEST/ProductDB/ProductData.db" įile currentDB = context.getDatabasePath("ProductData.db") I am not in position to completely clean it up, but by eyeball, I would switch copyFileIn() to: public boolean copyFileIn(Context context) It seems based on some ancient awful examples. That is really one of the first things that you need to do when running into problems: if you are logging information to Logcat ( () and Log.w() in your code), see what logs you are getting. You have not indicated what specific messages you are seeing in Logcat from any of this. That means we do not have to worry about Play Store restrictions and the like. ("currentDBPath = " + currentDBPath) įileChannel src = new FileInputStream(currentDB).getChannel() įileChannel dst = new FileOutputStream(backupDB).getChannel() Īfter I’ve got this part working again, I’ll be able to see if the database can still be read.Īt February 3, 2021, 6:06pm, mmurphy replied:įrom prior conversations, this app appears to be just for your personal use. ("Can't find currentDBPath") Īnd this exports it… public boolean copyFileOut(Context context)įile sd = context.getExternalFilesDir(null) String backupDBPath = "/BEST/ProductDB/ProductData.db" įile currentDB = new File(data, currentDBPath) įile backupDB = new File(sd, backupDBPath) įileChannel src = new FileInputStream(backupDB).getChannel() įileChannel dst = new FileOutputStream(currentDB).getChannel() String currentDBPath = "/data/.haden.bestmobile/databases/ProductData.db" SQLiteDatabase db = this.getReadableDatabase() This copies the db file in from an external source… public boolean copyFileIn(Context context)įile sd = new File(Environment.getExternalStorageDirectory() + "/Android/data/.haden.bestmobile/files") įile data = new File(Environment.getDataDirectory() + "/user/0/.haden.bestmobile") ![]() I’m assuming that the problem is very similar. However, the database still does not work. You have already helped me repair the issues I had reading and writing CSV files with OpenCSV. My app was working fine until the latest Android update and then everything broke. Unable to read SQLite database from app from the CommonsWare Community archivesĪt February 3, 2021, 5:30pm, AlanHaden asked:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |