-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated to Realm 5.0.0 and Android Studio 3.1
Changed package name Removed unused test folders
- Loading branch information
Showing
14 changed files
with
105 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 0 additions & 26 deletions
26
app/src/androidTest/java/com/example/chronvas/realmtesting/ExampleInstrumentedTest.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...e/chronvas/realmtesting/MainActivity.java → ...m/chronvas/realmtesting/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...example/chronvas/realmtesting/People.java → ...ava/com/chronvas/realmtesting/People.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.example.chronvas.realmtesting; | ||
package com.chronvas.realmtesting; | ||
|
||
import io.realm.RealmObject; | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
.../chronvas/realmtesting/RealmImporter.java → .../chronvas/realmtesting/RealmImporter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...hronvas/realmtesting/TransactionTime.java → ...hronvas/realmtesting/TransactionTime.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.chronvas.realmtesting.app; | ||
|
||
import android.app.Application; | ||
|
||
import com.chronvas.realmtesting.R; | ||
|
||
import java.io.File; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
import io.realm.Realm; | ||
import io.realm.RealmConfiguration; | ||
|
||
public class App extends Application { | ||
|
||
private static final String testDbFileName = "testdb.realm"; | ||
//Overwrite database on Application startup? - Optional | ||
private static final boolean shouldOverwriteDatabaseOnAppStartup = true; | ||
|
||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
|
||
if (shouldOverwriteDatabaseOnAppStartup) { | ||
copyBundledRealmFile(this.getResources().openRawResource(R.raw.testdb), testDbFileName); | ||
} else { | ||
//check if the db is already in place | ||
if (!fileFound(testDbFileName, this.getFilesDir())) { | ||
copyBundledRealmFile(this.getResources().openRawResource(R.raw.testdb), testDbFileName); | ||
} | ||
} | ||
|
||
//Config Realm for the application | ||
Realm.init(this); | ||
RealmConfiguration realmConfiguration = new RealmConfiguration.Builder() | ||
.name(testDbFileName) | ||
.build(); | ||
|
||
Realm.setDefaultConfiguration(realmConfiguration); | ||
} | ||
|
||
private void copyBundledRealmFile(InputStream inputStream, String outFileName) { | ||
try { | ||
File file = new File(this.getFilesDir(), outFileName); | ||
FileOutputStream outputStream = new FileOutputStream(file); | ||
byte[] buf = new byte[1024]; | ||
int bytesRead; | ||
while ((bytesRead = inputStream.read(buf)) > 0) { | ||
outputStream.write(buf, 0, bytesRead); | ||
} | ||
outputStream.close(); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
public boolean fileFound(String name, File file) { | ||
File[] list = file.listFiles(); | ||
if (list != null) | ||
for (File fil : list) { | ||
if (fil.isDirectory()) { | ||
fileFound(name, fil); | ||
} else if (name.equalsIgnoreCase(fil.getName())) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
} |
71 changes: 0 additions & 71 deletions
71
app/src/main/java/com/example/chronvas/realmtesting/app/App.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,42 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
|
||
android:orientation="vertical" | ||
<LinearLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:id="@+id/activity_main" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context="com.example.chronvas.realmtesting.MainActivity"> | ||
|
||
android:orientation="vertical" | ||
tools:context="com.chronvas.realmtesting.MainActivity"> | ||
|
||
<Button | ||
android:paddingTop="8dp" | ||
android:text="Import from Json" | ||
android:id="@+id/importbtn" | ||
style="@android:style/Widget.Button" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:id="@+id/importbtn" | ||
style="@android:style/Widget.Button" /> | ||
android:text="Import from Json" | ||
/> | ||
|
||
<Button | ||
android:text="count People" | ||
android:id="@+id/count" | ||
style="@android:style/Widget.Button" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:id="@+id/count" | ||
style="@android:style/Widget.Button" /> | ||
android:text="count People" | ||
/> | ||
|
||
<Button | ||
android:text="Change 1st person's name" | ||
android:id="@+id/changename" | ||
style="@android:style/Widget.Button" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:id="@+id/changename" | ||
style="@android:style/Widget.Button" /> | ||
android:text="Change 1st person's name" | ||
/> | ||
|
||
<Button | ||
android:text="View 1st person" | ||
android:id="@+id/viewname" | ||
style="@android:style/Widget.Button" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:id="@+id/viewname" | ||
style="@android:style/Widget.Button" /> | ||
android:text="View 1st person" | ||
/> | ||
</LinearLayout> |
17 changes: 0 additions & 17 deletions
17
app/src/test/java/com/example/chronvas/realmtesting/ExampleUnitTest.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters