├── app ├── .gitignore ├── src │ ├── main │ │ ├── ic_launcher-web.png │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── ic_launcher_background.xml │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ └── ic_launcher_foreground.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ └── ic_launcher_foreground.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ └── ic_launcher_foreground.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ └── ic_launcher_foreground.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ └── ic_launcher_foreground.png │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── layout │ │ │ │ ├── activity_second.xml │ │ │ │ └── activity_main.xml │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ └── drawable │ │ │ │ └── ic_launcher_background.xml │ │ ├── assets │ │ │ └── 数据库操作指南 │ │ ├── java │ │ │ └── com │ │ │ │ └── xsm │ │ │ │ └── easydb │ │ │ │ ├── SecondActivity.java │ │ │ │ ├── bean │ │ │ │ ├── Dog.java │ │ │ │ ├── People.java │ │ │ │ └── User.java │ │ │ │ ├── MyApplication.java │ │ │ │ └── MainActivity.java │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── xsm │ │ │ └── easydb │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── xsm │ │ └── easydb │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── db ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ └── values │ │ │ │ └── strings.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── xsm │ │ │ └── db │ │ │ ├── db │ │ │ ├── assist │ │ │ │ ├── IDaoAssist.java │ │ │ │ ├── Condition.java │ │ │ │ └── DaoAssist.java │ │ │ ├── IBaseDao.java │ │ │ ├── BaseDaoFactory.java │ │ │ └── BaseDao.java │ │ │ ├── utils │ │ │ └── Utils.java │ │ │ ├── annotation │ │ │ ├── DbFiled.java │ │ │ └── DbTable.java │ │ │ └── EasyDB.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── xsm │ │ │ └── db │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── xsm │ │ └── db │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .idea └── vcs.xml ├── .gitignore ├── gradle.properties ├── README.md ├── gradlew.bat └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /db/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':chargingview-release', ':db' 2 | -------------------------------------------------------------------------------- /app/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xiasm/EasyDB/HEAD/app/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /db/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | db 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | EasyDB 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xiasm/EasyDB/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xiasm/EasyDB/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xiasm/EasyDB/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xiasm/EasyDB/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xiasm/EasyDB/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xiasm/EasyDB/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /db/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xiasm/EasyDB/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/Xiasm/EasyDB/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/Xiasm/EasyDB/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/Xiasm/EasyDB/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xiasm/EasyDB/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xiasm/EasyDB/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xiasm/EasyDB/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xiasm/EasyDB/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xiasm/EasyDB/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xiasm/EasyDB/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/values/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #4259A6 4 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/assets/数据库操作指南: -------------------------------------------------------------------------------- 1 | ### 首先确保手机已ROOT 2 | 第一步:adb shell 3 | 第二部:cd /data/data/com.example.xuyushi.loadertest/databases 4 | 第三步:sqlite3 数据库名 5 | 第四部:.table (查看已建的表格) 6 | 第五步:select * from tablename; (后面的分号记得加) 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Mar 08 10:51:45 CST 2018 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip 7 | -------------------------------------------------------------------------------- /db/src/main/java/com/xsm/db/db/assist/IDaoAssist.java: -------------------------------------------------------------------------------- 1 | package com.xsm.db.db.assist; 2 | 3 | /** 4 | * Author: 夏胜明 5 | * Date: 2018/7/31 0031 6 | * Email: xiasem@163.com 7 | * Github:https://github.com/Xiasm 8 | * Description: 9 | */ 10 | public interface IDaoAssist { 11 | 12 | 13 | } 14 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /db/src/main/java/com/xsm/db/utils/Utils.java: -------------------------------------------------------------------------------- 1 | package com.xsm.db.utils; 2 | 3 | import android.text.TextUtils; 4 | 5 | /** 6 | * Author: 夏胜明 7 | * Date: 2018/7/31 0031 8 | * Email: xiasem@163.com 9 | * Github:https://github.com/Xiasm 10 | * Description: 11 | */ 12 | public class Utils { 13 | public static boolean isEmpty(String string) { 14 | return TextUtils.isEmpty(string); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /app/src/main/java/com/xsm/easydb/SecondActivity.java: -------------------------------------------------------------------------------- 1 | package com.xsm.easydb; 2 | 3 | import android.support.v7.app.AppCompatActivity; 4 | import android.os.Bundle; 5 | 6 | public class SecondActivity extends AppCompatActivity { 7 | 8 | @Override 9 | protected void onCreate(Bundle savedInstanceState) { 10 | super.onCreate(savedInstanceState); 11 | setContentView(R.layout.activity_second); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/java/com/xsm/easydb/bean/Dog.java: -------------------------------------------------------------------------------- 1 | package com.xsm.easydb.bean; 2 | 3 | /** 4 | * Author: 夏胜明 5 | * Date: 2018/3/8 0008 6 | * Email: xiasem@163.com 7 | * Description: 8 | */ 9 | 10 | public class Dog { 11 | private float weight; 12 | 13 | public float getWeight() { 14 | return weight; 15 | } 16 | 17 | public void setWeight(float weight) { 18 | this.weight = weight; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_second.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/java/com/xsm/easydb/MyApplication.java: -------------------------------------------------------------------------------- 1 | package com.xsm.easydb; 2 | 3 | import android.app.Application; 4 | 5 | import com.xsm.db.EasyDB; 6 | 7 | /** 8 | * Author: 夏胜明 9 | * Date: 2018/7/31 0031 10 | * Email: xiasem@163.com 11 | * Description: 12 | */ 13 | public class MyApplication extends Application { 14 | @Override 15 | public void onCreate() { 16 | super.onCreate(); 17 | EasyDB.init(this); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /db/src/test/java/com/xsm/db/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.xsm.db; 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/xsm/easydb/bean/People.java: -------------------------------------------------------------------------------- 1 | package com.xsm.easydb.bean; 2 | 3 | /** 4 | * Author: 夏胜明 5 | * Date: 2018/3/8 0008 6 | * Email: xiasem@163.com 7 | * Description: 8 | */ 9 | 10 | public class People { 11 | public People(int sex) { 12 | this.sex = sex; 13 | } 14 | 15 | private int sex; 16 | 17 | public int getSex() { 18 | return sex; 19 | } 20 | 21 | public void setSex(int sex) { 22 | this.sex = sex; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Intellij IDEA 2 | .idea/ 3 | *.iml 4 | *.ipr 5 | *.iws 6 | out/ 7 | 8 | # Gradle build folder 9 | build/ 10 | .gradle/ 11 | 12 | # Android 13 | local.properties 14 | bin/ 15 | gen/ 16 | 17 | # JNI compile files 18 | *.o 19 | *.o.d 20 | 21 | # OS autogen folder information 22 | .DS_Store 23 | Thumbs.db 24 | 25 | # Temp files 26 | *.bak 27 | *.tmp 28 | *.temp 29 | *.swp 30 | *.*~ 31 | ~*.* 32 | 33 | # Eclipse project files 34 | .classpath 35 | .settings/ 36 | .project 37 | 38 | #Android 2.2 C/C++ compile 39 | .externalNativeBuild/ 40 | -------------------------------------------------------------------------------- /db/src/main/java/com/xsm/db/db/IBaseDao.java: -------------------------------------------------------------------------------- 1 | package com.xsm.db.db; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Author: 夏胜明 7 | * Date: 2018/3/8 0008 8 | * Email: xiasem@163.com 9 | * Github:https://github.com/Xiasm 10 | * Description: 11 | */ 12 | 13 | public interface IBaseDao { 14 | 15 | long insert(T entity); 16 | 17 | long update(T entity, T where); 18 | 19 | int delete(T where); 20 | 21 | List query(T where); 22 | 23 | List query(T where, String orderBy, Integer startIndex, Integer limit); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /db/src/main/java/com/xsm/db/annotation/DbFiled.java: -------------------------------------------------------------------------------- 1 | package com.xsm.db.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Author: 夏胜明 10 | * Date: 2018/3/8 0008 11 | * Email: xiasem@163.com 12 | * Github:https://github.com/Xiasm 13 | * Description: 此注解用来修饰表字段,如果没有加此注解,默认用字段名作为列名 14 | */ 15 | @Target(ElementType.FIELD) 16 | @Retention(RetentionPolicy.RUNTIME) 17 | public @interface DbFiled { 18 | String value(); 19 | } 20 | -------------------------------------------------------------------------------- /db/src/main/java/com/xsm/db/annotation/DbTable.java: -------------------------------------------------------------------------------- 1 | package com.xsm.db.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Author: 夏胜明 10 | * Date: 2018/3/8 0008 11 | * Email: xiasem@163.com 12 | * Github:https://github.com/Xiasm 13 | * Description: 此注解用来定义表名,如果没有添加此注解,默认以类名作为表名 14 | */ 15 | @Target(ElementType.TYPE) 16 | @Retention(RetentionPolicy.RUNTIME) 17 | public @interface DbTable { 18 | String value(); 19 | } 20 | -------------------------------------------------------------------------------- /app/src/test/java/com/xsm/easydb/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.xsm.easydb; 2 | 3 | import android.util.Log; 4 | import android.widget.Toast; 5 | 6 | import com.xsm.easydb.bean.People; 7 | import com.xsm.easydb.db.BaseDao; 8 | import com.xsm.easydb.db.BaseDaoFactory; 9 | 10 | import org.junit.Test; 11 | 12 | import static org.junit.Assert.*; 13 | 14 | /** 15 | * Example local unit test, which will execute on the development machine (host). 16 | * 17 | * @see Testing documentation 18 | */ 19 | public class ExampleUnitTest { 20 | private static final String TAG = "ExampleUnitTest"; 21 | @Test 22 | public void addition_isCorrect() throws Exception { 23 | assertEquals(4, 2 + 2); 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /db/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/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 | -------------------------------------------------------------------------------- /db/src/androidTest/java/com/xsm/db/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.xsm.db; 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.xsm.db.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/xsm/easydb/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.xsm.easydb; 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() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.xsm.easydb", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /db/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 26 5 | 6 | 7 | 8 | defaultConfig { 9 | minSdkVersion 14 10 | targetSdkVersion 26 11 | versionCode 1 12 | versionName "1.0" 13 | 14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 15 | 16 | } 17 | 18 | buildTypes { 19 | release { 20 | minifyEnabled false 21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 22 | } 23 | } 24 | 25 | } 26 | 27 | dependencies { 28 | implementation fileTree(dir: 'libs', include: ['*.jar']) 29 | 30 | implementation 'com.android.support:appcompat-v7:26.1.0' 31 | testImplementation 'junit:junit:4.12' 32 | androidTestImplementation 'com.android.support.test:runner:1.0.1' 33 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' 34 | } 35 | -------------------------------------------------------------------------------- /db/src/main/java/com/xsm/db/EasyDB.java: -------------------------------------------------------------------------------- 1 | package com.xsm.db; 2 | 3 | import android.content.Context; 4 | 5 | /** 6 | * Author: 夏胜明 7 | * Date: 2018/7/31 0031 8 | * Email: xiasem@163.com 9 | * Github:https://github.com/Xiasm 10 | * Description: 11 | */ 12 | public class EasyDB { 13 | private static Context mApplicationContext; 14 | private static String mPackageName; 15 | private static boolean init = false; 16 | 17 | public static void init(Context context) { 18 | if (context == null) { 19 | throw new RuntimeException("init context is null"); 20 | } 21 | mApplicationContext = context.getApplicationContext(); 22 | mPackageName = mApplicationContext.getPackageName(); 23 | init = true; 24 | } 25 | 26 | public static Context getApplicationContext() { 27 | return mApplicationContext; 28 | } 29 | 30 | public static String getPackageName() { 31 | return mPackageName; 32 | } 33 | 34 | public static boolean isInit() { 35 | return init; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 26 5 | defaultConfig { 6 | applicationId "com.xsm.easydb" 7 | minSdkVersion 14 8 | targetSdkVersion 26 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | implementation fileTree(include: ['*.jar'], dir: 'libs') 23 | implementation 'com.android.support:appcompat-v7:26.1.0' 24 | implementation 'com.android.support.constraint:constraint-layout:1.0.2' 25 | testImplementation 'junit:junit:4.12' 26 | androidTestImplementation 'com.android.support.test:runner:1.0.1' 27 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' 28 | implementation project(':db') 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/xsm/easydb/bean/User.java: -------------------------------------------------------------------------------- 1 | package com.xsm.easydb.bean; 2 | 3 | 4 | import com.xsm.db.annotation.DbFiled; 5 | import com.xsm.db.annotation.DbTable; 6 | 7 | /** 8 | * Author: 夏胜明 9 | * Date: 2018/3/8 0008 10 | * Email: xiasem@163.com 11 | * Description: 12 | */ 13 | @DbTable("tb_user") 14 | public class User { 15 | private Integer id; 16 | @DbFiled("userName") 17 | private String name; 18 | private String phone; 19 | 20 | public int getId() { 21 | return id; 22 | } 23 | 24 | public void setId(int id) { 25 | this.id = id; 26 | } 27 | 28 | public String getName() { 29 | return name; 30 | } 31 | 32 | public void setName(String name) { 33 | this.name = name; 34 | } 35 | 36 | public String getPhone() { 37 | return phone; 38 | } 39 | 40 | public void setPhone(String phone) { 41 | this.phone = phone; 42 | } 43 | 44 | @Override 45 | public String toString() { 46 | return "User{" + 47 | "id=" + id + 48 | ", name='" + name + '\'' + 49 | ", phone='" + phone + '\'' + 50 | '}'; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /db/src/main/java/com/xsm/db/db/assist/Condition.java: -------------------------------------------------------------------------------- 1 | package com.xsm.db.db.assist; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Iterator; 5 | import java.util.Map; 6 | import java.util.Set; 7 | 8 | /** 9 | * Author: 夏胜明 10 | * Date: 2018/7/31 0031 11 | * Email: xiasem@163.com 12 | * Github:https://github.com/Xiasm 13 | * Description: 14 | */ 15 | public class Condition { 16 | public String whereCause; 17 | public String[] whereArgs; 18 | 19 | public Condition(Map whereCause) { 20 | ArrayList list = new ArrayList<>(); 21 | StringBuilder builder = new StringBuilder(); 22 | builder.append("1=1"); 23 | Set keys = whereCause.keySet(); 24 | Iterator iterator = keys.iterator(); 25 | while (iterator.hasNext()) { 26 | String key = iterator.next(); 27 | String value = whereCause.get(key); 28 | if (value != null) { 29 | builder.append(" and " + key + "=?"); 30 | list.add(value); 31 | } 32 | } 33 | this.whereCause = builder.toString(); 34 | this.whereArgs = list.toArray(new String[list.size()]); 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 |