Skip to content

Add possibility to use custom native library loader. #234

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 15, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 43 additions & 8 deletions src/net/sqlcipher/database/SQLiteDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,19 +163,54 @@ private static void loadICUData(Context context, File workingDir) {
}
}

/**
* Loads the native SQLCipher library into the application process.
*/
/**
* Implement this interface to provide custom strategy for loading jni libraries.
*/
public interface LibraryLoader {
/**
* Load jni libraries by given names.
* Straightforward implementation will be calling {@link System#loadLibrary(String name)}
* for every provided library name.
*
* @param libNames library names that sqlcipher need to load
*/
void loadLibraries(String... libNames);
}

/**
* Loads the native SQLCipher library into the application process.
*/
public static synchronized void loadLibs (Context context) {
loadLibs(context, context.getFilesDir());
}

/**
* Loads the native SQLCipher library into the application process.
*/
/**
* Loads the native SQLCipher library into the application process.
*/
public static synchronized void loadLibs (Context context, File workingDir) {
System.loadLibrary("sqlcipher");

loadLibs(context, workingDir, new LibraryLoader() {
@Override
public void loadLibraries(String... libNames) {
for (String libName : libNames) {
System.loadLibrary(libName);
}
}
});
}

/**
* Loads the native SQLCipher library into the application process.
*/
public static synchronized void loadLibs(Context context, LibraryLoader libraryLoader) {
loadLibs(context, context.getFilesDir(), libraryLoader);
}

/**
* Loads the native SQLCipher library into the application process.
*/
public static synchronized void loadLibs (Context context, File workingDir, LibraryLoader libraryLoader) {
libraryLoader.loadLibraries("sqlcipher");

// System.loadLibrary("stlport_shared");
// System.loadLibrary("sqlcipher_android");
// System.loadLibrary("database_sqlcipher");
Expand Down