Skip to content
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

insert() fixed on Android 10 and new SQLCipher version #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ android {

dependencies {
// See: https://www.zetetic.net/sqlcipher/sqlcipher-for-android/
compile 'net.zetetic:android-database-sqlcipher:4.0.0@aar'
compile 'net.zetetic:android-database-sqlcipher:4.2.0@aar'
}
Original file line number Diff line number Diff line change
Expand Up @@ -445,9 +445,45 @@ class SQLiteDatabaseHandler extends FlutterMethodCallHandler {
convertMapToContentValues(final Map<String, Object> input) {
assert(input != null);

final Parcel parcel = Parcel.obtain();
parcel.writeMap(input);
parcel.setDataPosition(0);
return ContentValues.CREATOR.createFromParcel(parcel);
ContentValues cv = new ContentValues(input.size());
for (final Map.Entry<String,Object> entry : input.entrySet()) {
final String key = entry.getKey();
final Object value = entry.getValue();

if (value == null) {
cv.putNull(key);
}
else if (value instanceof Boolean) {
cv.put(key, (Boolean)value);
}
else if (value instanceof Byte) {
cv.put(key, (Byte)value);
}
else if (value instanceof Short) {
cv.put(key, (Short)value);
}
else if (value instanceof Integer) {
cv.put(key, (Integer)value);
}
else if (value instanceof Long) {
cv.put(key, (Long)value);
}
else if (value instanceof Double) {
cv.put(key, (Double)value);
}
else if (value instanceof Float) {
cv.put(key, (Float)value);
}
else if (value instanceof String) {
cv.put(key, (String)value);
}
else if (value instanceof byte[]) {
cv.put(key, (byte[])value);
}
else {
throw new IllegalArgumentException("Unsupported class type " + value.getClass() + " for key " + key);
}
}
return cv;
}
}