Search in sources :

Example 6 with SQLiteDatabase

use of net.sqlcipher.database.SQLiteDatabase in project greenDAO by greenrobot.

the class EncryptedDbUtils method createDatabase.

public static Database createDatabase(Context context, String dbName, String password) {
    if (!loadedLibs) {
        loadedLibs = true;
        SQLiteDatabase.loadLibs(context);
    }
    SQLiteDatabase sqLiteDatabase;
    if (dbName == null) {
        sqLiteDatabase = SQLiteDatabase.create(null, password);
    } else {
        File dbFile = context.getDatabasePath(dbName);
        dbFile.getParentFile().mkdir();
        context.deleteDatabase(dbName);
        sqLiteDatabase = SQLiteDatabase.openOrCreateDatabase(dbFile, password, null);
    }
    return new EncryptedDatabase(sqLiteDatabase);
}
Also used : SQLiteDatabase(net.sqlcipher.database.SQLiteDatabase) EncryptedDatabase(org.greenrobot.greendao.database.EncryptedDatabase) File(java.io.File)

Example 7 with SQLiteDatabase

use of net.sqlcipher.database.SQLiteDatabase in project storymaker by StoryMaker.

the class ProjectsProvider method delete.

@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
    mCacheWordHandler.connectToService();
    setTimer(60000);
    SQLiteDatabase db = getDB();
    if (db != null) {
        int uriType = sURIMatcher.match(uri);
        switch(uriType) {
            case PROJECTS:
            case PROJECT_ID:
                return (new ProjectTable(db)).delete(getContext(), uri, selection, selectionArgs);
            case SCENES:
            case SCENE_ID:
                return (new SceneTable(db)).delete(getContext(), uri, selection, selectionArgs);
            case LESSONS:
            case LESSON_ID:
                return (new LessonTable(db)).delete(getContext(), uri, selection, selectionArgs);
            case MEDIA:
            case MEDIA_ID:
                return (new MediaTable(db)).delete(getContext(), uri, selection, selectionArgs);
            case AUTH:
            case AUTH_ID:
                return (new AuthTable(db)).delete(getContext(), uri, selection, selectionArgs);
            case TAGS:
            case TAG_ID:
            case DISTINCT_TAGS:
            case DISTINCT_TAG_ID:
                return (new TagTable(db)).delete(getContext(), uri, selection, selectionArgs);
            case JOBS:
            case JOB_ID:
                return (new JobTable(db)).delete(getContext(), uri, selection, selectionArgs);
            case PUBLISH_JOBS:
            case PUBLISH_JOB_ID:
                return (new PublishJobTable(db)).delete(getContext(), uri, selection, selectionArgs);
            case AUDIO_CLIPS:
            case AUDIO_CLIP_ID:
                return (new AudioClipTable(db)).delete(getContext(), uri, selection, selectionArgs);
            default:
                throw new IllegalArgumentException("Unknown URI");
        }
    }
    return 0;
}
Also used : SceneTable(org.storymaker.app.model.SceneTable) PublishJobTable(org.storymaker.app.model.PublishJobTable) JobTable(org.storymaker.app.model.JobTable) PublishJobTable(org.storymaker.app.model.PublishJobTable) MediaTable(org.storymaker.app.model.MediaTable) SQLiteDatabase(net.sqlcipher.database.SQLiteDatabase) AudioClipTable(org.storymaker.app.model.AudioClipTable) AuthTable(org.storymaker.app.model.AuthTable) TagTable(org.storymaker.app.model.TagTable) ProjectTable(org.storymaker.app.model.ProjectTable) LessonTable(org.storymaker.app.model.LessonTable)

Example 8 with SQLiteDatabase

use of net.sqlcipher.database.SQLiteDatabase in project storymaker by StoryMaker.

the class ProjectsProvider method insert.

@Nullable
@Override
public Uri insert(Uri uri, ContentValues values) {
    mCacheWordHandler.connectToService();
    setTimer(60000);
    SQLiteDatabase db = getDB();
    if (db != null) {
        long newId;
        int uriType = sURIMatcher.match(uri);
        switch(uriType) {
            case PROJECTS:
                return (new ProjectTable(db)).insert(getContext(), uri, values);
            case SCENES:
                return (new SceneTable(db)).insert(getContext(), uri, values);
            case LESSONS:
                return (new LessonTable(db)).insert(getContext(), uri, values);
            case MEDIA:
                return (new MediaTable(db)).insert(getContext(), uri, values);
            case AUTH:
                return (new AuthTable(db)).insert(getContext(), uri, values);
            case TAGS:
            case DISTINCT_TAGS:
                return (new TagTable(db)).insert(getContext(), uri, values);
            case JOBS:
                return (new JobTable(db)).insert(getContext(), uri, values);
            case PUBLISH_JOBS:
                return (new PublishJobTable(db)).insert(getContext(), uri, values);
            case AUDIO_CLIPS:
                return (new AudioClipTable(db)).insert(getContext(), uri, values);
            default:
                throw new IllegalArgumentException("Unknown URI");
        }
    }
    return null;
}
Also used : PublishJobTable(org.storymaker.app.model.PublishJobTable) JobTable(org.storymaker.app.model.JobTable) MediaTable(org.storymaker.app.model.MediaTable) AuthTable(org.storymaker.app.model.AuthTable) LessonTable(org.storymaker.app.model.LessonTable) SceneTable(org.storymaker.app.model.SceneTable) PublishJobTable(org.storymaker.app.model.PublishJobTable) SQLiteDatabase(net.sqlcipher.database.SQLiteDatabase) AudioClipTable(org.storymaker.app.model.AudioClipTable) TagTable(org.storymaker.app.model.TagTable) ProjectTable(org.storymaker.app.model.ProjectTable) Nullable(android.support.annotation.Nullable)

Aggregations

SQLiteDatabase (net.sqlcipher.database.SQLiteDatabase)8 AudioClipTable (org.storymaker.app.model.AudioClipTable)4 AuthTable (org.storymaker.app.model.AuthTable)4 JobTable (org.storymaker.app.model.JobTable)4 LessonTable (org.storymaker.app.model.LessonTable)4 MediaTable (org.storymaker.app.model.MediaTable)4 ProjectTable (org.storymaker.app.model.ProjectTable)4 PublishJobTable (org.storymaker.app.model.PublishJobTable)4 SceneTable (org.storymaker.app.model.SceneTable)4 TagTable (org.storymaker.app.model.TagTable)4 File (java.io.File)3 Nullable (android.support.annotation.Nullable)2 SharedPreferences (android.content.SharedPreferences)1 Cursor (android.database.Cursor)1 Closeable (java.io.Closeable)1 IOException (java.io.IOException)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Cursor (net.sqlcipher.Cursor)1