├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ ├── layout │ │ │ │ └── activity_main.xml │ │ │ └── drawable │ │ │ │ └── ic_launcher_background.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── android │ │ │ │ └── databaseexpoter │ │ │ │ ├── common │ │ │ │ ├── DataBeanClass.kt │ │ │ │ ├── SampleApplication.kt │ │ │ │ └── AssetManager.kt │ │ │ │ ├── db │ │ │ │ ├── entity │ │ │ │ │ ├── SecondTableEntity.kt │ │ │ │ │ └── FirstTableEntity.kt │ │ │ │ ├── dao │ │ │ │ │ ├── FirstTableDao.kt │ │ │ │ │ └── SecondTableDao.kt │ │ │ │ ├── repository │ │ │ │ │ ├── FirstTableRepo.kt │ │ │ │ │ └── SecondTableRepo.kt │ │ │ │ └── AppDatabase.kt │ │ │ │ ├── SampleForKotlin.kt │ │ │ │ └── MainActivity.java │ │ ├── assets │ │ │ └── dbExporter.json │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── android │ │ │ └── databaseexpoter │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── example │ │ └── android │ │ └── databaseexpoter │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── dbexporterlibrary ├── .gitignore ├── libs │ └── opencsv-2.3.jar ├── src │ ├── main │ │ ├── res │ │ │ └── values │ │ │ │ └── strings.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── android │ │ │ └── dbexporterlibrary │ │ │ ├── ExporterListener.kt │ │ │ └── ExportDbUtil.kt │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── android │ │ │ └── dbexporterlibrary │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── android │ │ └── dbexporterlibrary │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .idea ├── vcs.xml ├── runConfigurations.xml ├── gradle.xml ├── codeStyles │ └── Project.xml └── misc.xml ├── .gitignore ├── gradle.properties ├── gradlew.bat ├── README.md ├── gradlew └── LICENSE /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /dbexporterlibrary/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':dbexporterlibrary' 2 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | DataBaseExpoter 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prabhat1707/DbExporterHelper/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /dbexporterlibrary/libs/opencsv-2.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prabhat1707/DbExporterHelper/HEAD/dbexporterlibrary/libs/opencsv-2.3.jar -------------------------------------------------------------------------------- /dbexporterlibrary/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | DbExporterLibrary 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prabhat1707/DbExporterHelper/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prabhat1707/DbExporterHelper/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prabhat1707/DbExporterHelper/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prabhat1707/DbExporterHelper/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prabhat1707/DbExporterHelper/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prabhat1707/DbExporterHelper/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prabhat1707/DbExporterHelper/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prabhat1707/DbExporterHelper/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prabhat1707/DbExporterHelper/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prabhat1707/DbExporterHelper/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /dbexporterlibrary/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches/build_file_checksums.ser 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | .DS_Store 9 | /build 10 | /captures 11 | .externalNativeBuild 12 | -------------------------------------------------------------------------------- /dbexporterlibrary/src/main/java/com/android/dbexporterlibrary/ExporterListener.kt: -------------------------------------------------------------------------------- 1 | package com.android.dbexporterlibrary 2 | 3 | interface ExporterListener { 4 | fun success(s: String) 5 | 6 | fun fail(message: String,exception:String) 7 | } -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #008577 4 | #00574B 5 | #D81B60 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/example/android/databaseexpoter/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.example.android.databaseexpoter; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /dbexporterlibrary/src/test/java/com/android/dbexporterlibrary/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.android.dbexporterlibrary; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/databaseexpoter/common/DataBeanClass.kt: -------------------------------------------------------------------------------- 1 | package com.example.android.databaseexpoter.common 2 | 3 | import com.example.android.databaseexpoter.db.entity.FirstTableEntity 4 | import com.example.android.databaseexpoter.db.entity.SecondTableEntity 5 | import com.google.gson.annotations.SerializedName 6 | 7 | class DataBeanClass { 8 | @SerializedName("first_table") 9 | lateinit var systemFeatures: List 10 | 11 | @SerializedName("second_table") 12 | lateinit var preferenceData: List 13 | } -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/databaseexpoter/db/entity/SecondTableEntity.kt: -------------------------------------------------------------------------------- 1 | package com.example.android.databaseexpoter.db.entity 2 | 3 | import android.arch.persistence.room.ColumnInfo 4 | import android.arch.persistence.room.Entity 5 | import android.arch.persistence.room.PrimaryKey 6 | import com.google.gson.annotations.SerializedName 7 | 8 | @Entity(tableName = "secondTable") 9 | class SecondTableEntity { 10 | @PrimaryKey 11 | @ColumnInfo(name = "id") 12 | @SerializedName("id") 13 | var id: Int = 0 14 | 15 | @ColumnInfo(name = "name") 16 | @SerializedName("name") 17 | var name: String = "" 18 | } -------------------------------------------------------------------------------- /app/src/main/assets/dbExporter.json: -------------------------------------------------------------------------------- 1 | { 2 | "first_table": [ 3 | { 4 | "id": 101, 5 | "name": "USER1", 6 | "type": "CUSTOMER" 7 | }, 8 | { 9 | "id": 102, 10 | "name": "USER2", 11 | "type": "EMPLYOEE" 12 | }, 13 | { 14 | "id": 103, 15 | "name": "USER3", 16 | "type": "CUSTOMER" 17 | }, 18 | { 19 | "id": 104, 20 | "name": "USER4", 21 | "type": "lCUSTOMER" 22 | } 23 | 24 | ], 25 | "second_table": [ 26 | { 27 | "id": 1, 28 | "name": "CUSTOMER" 29 | }, 30 | { 31 | "id": 2, 32 | "name": "EMPLYOEE" 33 | } 34 | ] 35 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/databaseexpoter/db/entity/FirstTableEntity.kt: -------------------------------------------------------------------------------- 1 | package com.example.android.databaseexpoter.db.entity 2 | 3 | import android.arch.persistence.room.ColumnInfo 4 | import android.arch.persistence.room.Entity 5 | import android.arch.persistence.room.PrimaryKey 6 | import com.google.gson.annotations.SerializedName 7 | 8 | @Entity(tableName = "firstTabel") 9 | class FirstTableEntity { 10 | 11 | @PrimaryKey 12 | @ColumnInfo(name = "id") 13 | @SerializedName("id") 14 | var id: Int = 0 15 | 16 | @ColumnInfo(name = "name") 17 | @SerializedName("name") 18 | var name: String = "" 19 | 20 | @ColumnInfo(name = "type") 21 | @SerializedName("type") 22 | var type: String = "" 23 | 24 | 25 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/databaseexpoter/common/SampleApplication.kt: -------------------------------------------------------------------------------- 1 | package com.example.android.databaseexpoter.common 2 | 3 | import android.app.Application 4 | import com.tanzanite.blubox.db.AppDatabase 5 | import android.arch.persistence.room.Room 6 | 7 | 8 | 9 | class SampleApplication : Application() { 10 | 11 | companion object { 12 | @JvmStatic 13 | private lateinit var mInstance: SampleApplication 14 | 15 | @JvmStatic 16 | fun getInstance(): SampleApplication { 17 | return mInstance 18 | } 19 | } 20 | 21 | override fun onCreate() { 22 | super.onCreate() 23 | mInstance = this 24 | AppDatabase.getInstance(this)?.openHelper?.writableDatabase 25 | } 26 | } -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/databaseexpoter/db/dao/FirstTableDao.kt: -------------------------------------------------------------------------------- 1 | package com.example.android.databaseexpoter.db.dao 2 | 3 | import android.arch.lifecycle.LiveData 4 | import android.arch.persistence.room.Dao 5 | import android.arch.persistence.room.Insert 6 | import android.arch.persistence.room.OnConflictStrategy 7 | import android.arch.persistence.room.Query 8 | import com.example.android.databaseexpoter.db.entity.FirstTableEntity 9 | 10 | @Dao 11 | interface FirstTableDao { 12 | @Insert 13 | fun insertList(data: List) 14 | 15 | @Query("SELECT * FROM firstTabel") 16 | fun getAllData(): LiveData> 17 | 18 | @Insert(onConflict = OnConflictStrategy.REPLACE) 19 | fun insert(systemFeatureEntity: FirstTableEntity) 20 | 21 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/databaseexpoter/common/AssetManager.kt: -------------------------------------------------------------------------------- 1 | @file:JvmName("AssetManager") 2 | 3 | package com.example.android.databaseexpoter.common 4 | 5 | import android.content.Context 6 | import java.io.IOException 7 | import java.nio.charset.Charset 8 | 9 | fun loadSystemFeatureDataFromAsset(context: Context): String? { 10 | val json: String 11 | 12 | try { 13 | val assetManager = context.assets 14 | val inputStream = assetManager.open("dbExporter.json") 15 | val size = inputStream.available() 16 | val buffer = ByteArray(size) 17 | inputStream.read(buffer) 18 | inputStream.close() 19 | json = String(buffer, Charset.forName("UTF-8")) 20 | } catch (ex: IOException) { 21 | ex.printStackTrace() 22 | return null 23 | } 24 | 25 | return json 26 | } -------------------------------------------------------------------------------- /dbexporterlibrary/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/databaseexpoter/db/dao/SecondTableDao.kt: -------------------------------------------------------------------------------- 1 | package com.example.android.databaseexpoter.db.dao 2 | 3 | import android.arch.lifecycle.LiveData 4 | import android.arch.persistence.room.Dao 5 | import android.arch.persistence.room.Insert 6 | import android.arch.persistence.room.OnConflictStrategy 7 | import android.arch.persistence.room.Query 8 | import com.example.android.databaseexpoter.db.entity.FirstTableEntity 9 | import com.example.android.databaseexpoter.db.entity.SecondTableEntity 10 | 11 | @Dao 12 | interface SecondTableDao { 13 | @Insert 14 | fun insertList(data: List) 15 | 16 | @Query("SELECT * FROM firstTabel") 17 | fun getAllData(): LiveData> 18 | 19 | @Insert(onConflict = OnConflictStrategy.REPLACE) 20 | fun insert(secondTableEntity: SecondTableEntity) 21 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/databaseexpoter/SampleForKotlin.kt: -------------------------------------------------------------------------------- 1 | package com.example.android.databaseexpoter 2 | 3 | import android.os.Bundle 4 | import android.support.v7.app.AppCompatActivity 5 | import com.android.dbexporterlibrary.ExportDbUtil 6 | import com.android.dbexporterlibrary.ExporterListener 7 | 8 | class SampleForKotlin : AppCompatActivity(),ExporterListener { 9 | override fun fail(message: String, exception: String) { 10 | 11 | } 12 | 13 | override fun success(s: String) { 14 | 15 | } 16 | 17 | lateinit var dbUtil:ExportDbUtil 18 | override fun onCreate(savedInstanceState: Bundle?) { 19 | super.onCreate(savedInstanceState) 20 | setContentView(R.layout.activity_main) 21 | val dbToCsv = ExportDbUtil(this, "sampleDbExporter", "library Test",this) 22 | dbToCsv.exportAllTables("test.csv") 23 | } 24 | } -------------------------------------------------------------------------------- /app/src/androidTest/java/com/example/android/databaseexpoter/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.example.android.databaseexpoter; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.example.android.databaseexpoter", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /dbexporterlibrary/src/androidTest/java/com/android/dbexporterlibrary/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.android.dbexporterlibrary; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.android.dbexporterlibrary.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /dbexporterlibrary/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'com.android.library' 4 | apply plugin: 'com.github.dcendents.android-maven' 5 | group = 'com.github.prabhat1707' 6 | 7 | android { 8 | compileSdkVersion 28 9 | 10 | 11 | 12 | defaultConfig { 13 | minSdkVersion 18 14 | targetSdkVersion 28 15 | versionCode 1 16 | versionName "1.0" 17 | 18 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 19 | 20 | } 21 | 22 | buildTypes { 23 | release { 24 | minifyEnabled false 25 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 26 | } 27 | } 28 | 29 | } 30 | 31 | dependencies { 32 | implementation fileTree(dir: 'libs', include: ['*.jar']) 33 | 34 | implementation 'com.android.support:appcompat-v7:28.0.0' 35 | testImplementation 'junit:junit:4.12' 36 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 37 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 38 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 39 | implementation files('libs/opencsv-2.3.jar') 40 | } 41 | repositories { 42 | mavenCentral() 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/databaseexpoter/db/repository/FirstTableRepo.kt: -------------------------------------------------------------------------------- 1 | package com.example.android.databaseexpoter.db.repository 2 | 3 | import android.app.Application 4 | import android.arch.lifecycle.LiveData 5 | import android.os.AsyncTask 6 | import com.example.android.databaseexpoter.db.dao.FirstTableDao 7 | import com.example.android.databaseexpoter.db.entity.FirstTableEntity 8 | import com.tanzanite.blubox.db.AppDatabase 9 | 10 | 11 | class FirstTableRepo(application: Application) { 12 | 13 | private val mFirstTableDao: FirstTableDao? 14 | private val mAllData: LiveData>? 15 | 16 | init { 17 | val db = AppDatabase.getInstance(application) 18 | mFirstTableDao = db!!.firstTableDao() 19 | mAllData = mFirstTableDao.getAllData() 20 | } 21 | 22 | fun insert(systemFeatureEntity: FirstTableEntity) { 23 | InsertAsyncTask(mFirstTableDao).execute(systemFeatureEntity) 24 | } 25 | 26 | fun insertData(data: List) { 27 | mFirstTableDao?.insertList(data) 28 | } 29 | 30 | fun getAllSystemData(): LiveData>? { 31 | return mAllData 32 | } 33 | 34 | 35 | private class InsertAsyncTask(private val mAsyncTaskDao: FirstTableDao?) : AsyncTask() { 36 | 37 | override fun doInBackground(vararg params: FirstTableEntity): Void? { 38 | mAsyncTaskDao?.insert(params[0]) 39 | return null 40 | } 41 | } 42 | 43 | 44 | } -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-kapt' 4 | 5 | 6 | android { 7 | compileSdkVersion 28 8 | defaultConfig { 9 | applicationId "com.example.android.databaseexpoter" 10 | minSdkVersion 18 11 | targetSdkVersion 28 12 | versionCode 1 13 | versionName "1.0" 14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 15 | } 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 20 | } 21 | } 22 | } 23 | 24 | dependencies { 25 | implementation fileTree(include: ['*.jar'], dir: 'libs') 26 | implementation 'com.android.support:appcompat-v7:28.0.0' 27 | implementation 'com.android.support.constraint:constraint-layout:1.1.3' 28 | testImplementation 'junit:junit:4.12' 29 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 30 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 31 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 32 | implementation 'android.arch.persistence.room:runtime:1.1.1' 33 | annotationProcessor 'android.arch.persistence.room:compiler:1.1.1' 34 | kapt 'android.arch.persistence.room:compiler:1.1.1' 35 | implementation 'com.google.code.gson:gson:2.8.5' 36 | implementation project(':dbexporterlibrary') 37 | } 38 | repositories { 39 | mavenCentral() 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/databaseexpoter/db/repository/SecondTableRepo.kt: -------------------------------------------------------------------------------- 1 | package com.example.android.databaseexpoter.db.repository 2 | 3 | import android.app.Application 4 | import android.arch.lifecycle.LiveData 5 | import android.os.AsyncTask 6 | import com.example.android.databaseexpoter.db.dao.FirstTableDao 7 | import com.example.android.databaseexpoter.db.dao.SecondTableDao 8 | import com.example.android.databaseexpoter.db.entity.FirstTableEntity 9 | import com.example.android.databaseexpoter.db.entity.SecondTableEntity 10 | import com.tanzanite.blubox.db.AppDatabase 11 | 12 | class SecondTableRepo(application: Application) { 13 | private val mSecondTableDao: SecondTableDao? 14 | private val mAllData: LiveData>? 15 | 16 | init { 17 | val db = AppDatabase.getInstance(application) 18 | mSecondTableDao = db!!.secondTableDao() 19 | mAllData = mSecondTableDao.getAllData() 20 | } 21 | 22 | fun insert(secondTableEntity: SecondTableEntity) { 23 | InsertAsyncTask(mSecondTableDao).execute(secondTableEntity) 24 | } 25 | 26 | fun insertData(data: List) { 27 | mSecondTableDao?.insertList(data) 28 | } 29 | 30 | fun getAllSystemData(): LiveData>? { 31 | return mAllData 32 | } 33 | 34 | 35 | private class InsertAsyncTask(private val mAsyncTaskDao: SecondTableDao?) : AsyncTask() { 36 | 37 | override fun doInBackground(vararg params: SecondTableEntity): Void? { 38 | mAsyncTaskDao?.insert(params[0]) 39 | return null 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/databaseexpoter/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.example.android.databaseexpoter; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.view.View; 6 | import android.widget.Button; 7 | import android.widget.Toast; 8 | 9 | import com.android.dbexporterlibrary.ExportDbUtil; 10 | import com.android.dbexporterlibrary.ExporterListener; 11 | 12 | import org.jetbrains.annotations.NotNull; 13 | 14 | public class MainActivity extends AppCompatActivity implements ExporterListener { 15 | private ExportDbUtil exportDbUtil; 16 | 17 | @Override 18 | protected void onCreate(Bundle savedInstanceState) { 19 | super.onCreate(savedInstanceState); 20 | setContentView(R.layout.activity_main); 21 | exportDbUtil = new ExportDbUtil(this, "sampleDbExporter", "library Test", this); 22 | 23 | 24 | } 25 | 26 | @Override 27 | public void success(@NotNull String s) { 28 | Toast.makeText(this, s, Toast.LENGTH_SHORT).show(); 29 | } 30 | 31 | @Override 32 | public void fail(@NotNull String message, @NotNull String exception) { 33 | Toast.makeText(this, message, Toast.LENGTH_SHORT).show(); 34 | } 35 | 36 | public void exportToCsv(View view) { 37 | exportDbUtil.exportAllTables("test.csv"); 38 | } 39 | 40 | public void exportSingleTable(View view) { 41 | exportDbUtil.exportSingleTable("firstTabel","test.csv"); 42 | } 43 | 44 | public void importDb(View view) { 45 | if (exportDbUtil.isBackupExist("library Test")) { 46 | exportDbUtil.importDBFile("/data/com.example.android.databaseexpoter/databases/"); 47 | } else { 48 | Toast.makeText(this, "no Backup", Toast.LENGTH_SHORT).show(); 49 | 50 | } 51 | } 52 | 53 | public void exportDB(View view) { 54 | exportDbUtil.exportDb("/data/com.example.android.databaseexpoter/databases/"); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 31 | 32 | 33 | 34 | 35 | 36 | 38 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 |