Xposed module with sqlite (without context

I want to use sqlite in my xposed module but i don't have any activity or context to send the database constructor.
Is it possible to overcome this?
I tried to send null as a context, but i'm getting nullPointerException when i try to open the database.

I tried the AndroidAppHelper.currentApplication() option, but it returns NULL in my case...

If you are editing a database using sqlite and the current process you are hooking as no context reference, you can use root to set the database file to readable, then have your own service running in the background with a file observer tracking changes to a file on the device. Inside xposed module you will write to the file with a command instructing the file observer what to do. Then your service will "hear" the command and execute the changes needed.

If you are editing a database using sqlite and the current process you are hooking as no context reference, you can use root to set the database file to readable, then have your own service running in the background with a file observer tracking changes to a file on the device. Inside xposed module you will write to the file with a command instructing the file observer what to do. Then your service will "hear" the command and execute the changes needed.

I plan on writing up a guide for this. Tomorrow

Thanks, I'll be happy to read your guide and learn new stuff

Anyway, I read that it's possible to use Sqlite DB without using SQLiteOpenHelper, this way, i don't need context.
the problem is that when i do it i get exception:

android.database.sqlite.SQLiteCantOpenDatabaseExce ption: unknown error (code 14): Could not open database

Let's differentiate between two things: your module (normal code) and the hooked process (the Xposed code).

Remember that hooked code runs as the hooked process (that is, the app you're hooking — *not* your module), so you won't be able to write to your module's data directory.

I don't know if you can change that. Maybe you could create the database and use Context.MODE_WORLD_WRITABLE (from your module, when it firsts open), but I don't think you'll have any luck creating it from the hooked process directly.

Let's differentiate between two things: your module (normal code) and the hooked process (the Xposed code).

Remember that hooked code runs as the hooked process (that is, the app you're hooking — *not* your module), so you won't be able to write to your module's data directory.

I don't know if you can change that. Maybe you could create the database and use Context.MODE_WORLD_WRITABLE (from your module, when it firsts open), but I don't think you'll have any luck creating it from the hooked process directly.

So where is the best place to use AndroidAppHelper.currentApplication(); so it won't return null and i will be able to use it in my hooked method?

XDA Developers was founded by developers, for developers. It is now a valuable resource for people who want to make the most of their mobile devices, from customizing the look and feel to adding new functionality.Are you a developer?