I'm setting up my SQLite on an android studio in both my pc and mac, but when I open the databases file using txt at the device file explorer, This is the db file using text open in the android studio this is the error. Then I try to fix this by change encoding to GBK. It is still unable to show the data. Also, I try to save the db file and open in SQLite viewer plugin in google chrome, it's said that the table was not found. And I was really sure database was working fine with my teammate computer.
3 Answers
Android Studio cannot open SQLite files directly. The file according to the screen shot. Appears to be a valid SQLite file that is the first 16 characters appear to be The header string: "SQLite format 3\000" as described in Database File Format.
What you need to do is place the file in the assets folder (your may need to create the folder) of the project (I suggest copying the file outside of Android Studio) (databases folder within the assets folder if using SQLiteAssetHelper).
Your App should then copy the database (the file) into it's location (typically the directory data/data/your_package/databases, not that you should hard code this but get it using the Context's getDatabasePath
method), if the database file doesn't exist, and then access the database as an SQLiteDatabase object.
SQLiteAssetHelper, as linked above, makes this relatively simple. However, it does not appear to handle Android Pie. There are numerous posts regrading copying a pre-existing database e.g. The Answer Here (copes with Android Pie).
Re the comment
how to set back the file editor default as db type, because my file inside of Android studio was txt type
Use File/Settings/Editor/File Types.

- 51,415
- 16
- 49
- 68
You can not open db as text file. when you talk about Unicode you are talking about characters but db data is not some characters like a text file. It is binary file. db may contain images or any other binary data.
You can use SQLite Browser: https://sqlitebrowser.org

- 3,630
- 2
- 18
- 29
-
how to set back the file editor default as db type, because my file inside of Android studio was txt type. – learnisgood Apr 11 '19 at 21:36
-
@learnisgood you can not change Android Studio editors but if you use Windows OS you can right click on any file select `properties` and select `change` button from `opens with` section. also see this https://www.lifewire.com/how-to-change-file-associations-in-windows-2624477 – ygngy Apr 11 '19 at 23:01
You can also use a free tool called SQLite Studio to create, modify, delete SQLite databases, tables and data. https://sqlitestudio.pl/index.rvt
In a pinch, you can also use SQLite from a command line. On a mac, you would open your terminal window to do this.

- 1,698
- 1
- 9
- 13