1

I am going to data/data/myPackage in emulator and download these three files about my apps database :

enter image description here

But when i import it to DB browser i faced with this error :

enter image description here

I think the problem is about permissions(-rw------) because when i import other database that has this (-rw-rw----),DB browser can open it.

Then how can i change permission or open my room database in DB browser?

This is my room config :

@Database(entities = {Authentication.class}, version = 1)
public abstract class InsensitiveDatabase extends RoomDatabase {

    private static InsensitiveDatabase INSTANCE;

    public abstract AuthenticationDao authenticationDao();

    public static InsensitiveDatabase getInsensitiveDatabase(Context context) {
        if (INSTANCE == null) {
            Editable editable = new SpannableStringBuilder("1234");
            SafeHelperFactory factory = SafeHelperFactory.fromUser(editable);
            INSTANCE = Room.databaseBuilder(context, InsensitiveDatabase.class, "insensitive.db")
                    .openHelperFactory(factory)
                    .build();
        }
        return INSTANCE;
    }
}
milad salimi
  • 1,580
  • 2
  • 12
  • 31
  • which file are you opening in SqliteBrowser ? – m3g4tr0n Jun 17 '19 at 10:49
  • @m3g4tr0n , the first one , but i tried all of them – milad salimi Jun 17 '19 at 10:50
  • Can you upload your file somewhere from where I could download – m3g4tr0n Jun 17 '19 at 10:51
  • I think its about permission , what do you think? – milad salimi Jun 17 '19 at 10:51
  • I don't think so, Sqlite Browser clearly says Invalid File Format – m3g4tr0n Jun 17 '19 at 10:52
  • @m3g4tr0n , [link](https://filebin.net/bj9wjvck01hbtbl5) – milad salimi Jun 17 '19 at 10:54
  • Just tried, I am getting a different error : Could Not Open Database File, Reason file is not a Database – m3g4tr0n Jun 17 '19 at 10:58
  • Add Some Data to tables then try exporting once again – m3g4tr0n Jun 17 '19 at 10:59
  • @m3g4tr0n , you import it in DB browser or other one? – milad salimi Jun 17 '19 at 11:02
  • Try adding ```exportSchema``` in ```@Database(entities = {Authentication.class}, version = 1, exportSchema = false) ``` – m3g4tr0n Jun 17 '19 at 11:02
  • Definitely not an SQLite Database first 16 bytes should be **SQLite format 3\000** instead the first bytes are ãOÀDó7QXªäÒŽ×ðôdwÔ¢. I'd suggest try copying the 3 files again. – MikeT Jun 17 '19 at 11:02
  • @MikeT: This is a SQLCipher for Android database; I do not know if they share the same byte header. – CommonsWare Jun 17 '19 at 11:03
  • @CommonsWare then it would need to be opened with the key as I believe that decrypts the entire file. – MikeT Jun 17 '19 at 11:05
  • 1
    "how can i change permission" -- you need to be copying the files down to your development machine before attempting to use them in some external tool. "open my room database in DB browser?" -- I have no idea if that tool supports SQLCipher databases. – CommonsWare Jun 17 '19 at 11:06
  • @CommonsWare I believe you can IF you have a version of DB Browser with SQliteCipher. – MikeT Jun 17 '19 at 11:09
  • Thanks for your answering every body , @CommonsWare , you mean is that DB browser does not support SQLCipher database? – milad salimi Jun 17 '19 at 11:19
  • 2
    at [Encrypted Databases](https://github.com/sqlitebrowser/sqlitebrowser/wiki/Encrypted-Databases) it says *DB Browser for SQLite can be downloaded with SQLCipher support on Mac OSX and Windows, or if you compile it yourself you can get support on Linux.* But then says *You can only encrypt an existing database, so if you want a new encrypted database you first need to create a new database file and then encrypt it.* So wondering if it's a self contained so can't open a db encrypted elsewhere. – MikeT Jun 17 '19 at 11:29
  • 1
    "you mean is that DB browser does not support SQLCipher database?" -- as I wrote, I have no idea if that tool supports SQLCipher databases. – CommonsWare Jun 17 '19 at 11:37
  • Most likely sqlite browser doesn't work properly, try other ones – LeTadas Jun 17 '19 at 13:37
  • @kosas , i use Stetho [link](https://stackoverflow.com/questions/29138442/browse-sqlite-database-from-android-studio) library that faceboook release it and sqliteviewer but does not show anything again – milad salimi Jun 18 '19 at 05:11

2 Answers2

1

As i found The DB browser that developed in Linux cant open my encrypted room database because i open it in MAC OS.

You can see more detail in this issue that i open it,i hope that this is useful for your problem.

milad salimi
  • 1,580
  • 2
  • 12
  • 31
0

If you are using SQLCipher in Room DB then it will not show in App Inspection->Database Inspector

Remove this below line and check-

.openHelperFactory(factory) //will not show in App Inspection ->Database inspection

vikas khot
  • 31
  • 2