Skip to content
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
3 changes: 2 additions & 1 deletion MemeifyMe/.idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions MemeifyMe/.idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 2 additions & 38 deletions MemeifyMe/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion MemeifyMe/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion MemeifyMe/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 0 additions & 19 deletions MemeifyMe/MemeifyMe.iml

This file was deleted.

97 changes: 0 additions & 97 deletions MemeifyMe/app/app.iml

This file was deleted.

3 changes: 3 additions & 0 deletions MemeifyMe/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.j256.ormlite:ormlite-android:4.48'
compile 'com.jakewharton:butterknife:7.0.1'

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package accesscode.c4q.nyc.memeifyme;

import android.content.Context;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;

import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper;
import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.table.TableUtils;

/**
* Created by c4q-joshelynvivas on 7/23/15.
*/
public class DatabaseOpenHelper extends OrmLiteSqliteOpenHelper {
private static final String MYDB = "mydb.db";
private static final int VERSION = 1;

//This is the constructor that is called by mHelper
private static DatabaseOpenHelper mHelper;

//It will evaluate if there is a database, and the version number
private DatabaseOpenHelper(Context context) {
super(context, MYDB, null, VERSION);
}

//This ensures there is only one helper in this class. We must prevent it from the MainActivity.
//Hence, this will create a helper ONLY if there isn't one already
public static DatabaseOpenHelper getInstance(Context context){
if (mHelper == null) {
mHelper = new DatabaseOpenHelper(context.getApplicationContext());
}
return mHelper;
}

@Override
public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) {

//We don't make the column. A class will do that for us based called TemplateMeme class

try {
TableUtils.createTable(connectionSource, TemplateMeme.class);
} catch (SQLException e) {
e.printStackTrace();
} catch (java.sql.SQLException e) {
e.printStackTrace();
}
}

@Override
public void onUpgrade(SQLiteDatabase database, ConnectionSource connectionSource, int oldVersion, int newVersion) {

//If the table exists, it will delete the entire table and then create it again.
//Then it will call onCreate to make the table

try {
TableUtils.dropTable(connectionSource, TemplateMeme.class, true);
onCreate(database, connectionSource);
} catch (SQLException e) {
e.printStackTrace();
} catch (java.sql.SQLException e) {
e.printStackTrace();
}
}

public void insertRow(int picture) {

//Create instance of TemplateMeme
TemplateMeme meme = new TemplateMeme(picture);

try {
getDao(TemplateMeme.class).create(meme);
} catch (SQLException e) {
e.printStackTrace();
} catch (java.sql.SQLException e) {
e.printStackTrace();
}


}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void onClick(View view) {
startActivity(gallery);
break;
case R.id.btn_template:
Intent template = new Intent(this, Template.class);
Intent template = new Intent(this, TemplateActivity.class);
startActivity(template);
break;
case R.id.btn_doge:
Expand Down
Loading