diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..2b75303
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,13 @@
+*.iml
+.gradle
+/local.properties
+/.idea/caches
+/.idea/libraries
+/.idea/modules.xml
+/.idea/workspace.xml
+/.idea/navEditor.xml
+/.idea/assetWizardSettings.xml
+.DS_Store
+/build
+/captures
+.externalNativeBuild
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
new file mode 100644
index 0000000..30aa626
--- /dev/null
+++ b/.idea/codeStyles/Project.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..c2bae49
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
new file mode 100644
index 0000000..f43d428
--- /dev/null
+++ b/.idea/gradle.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/json2java.xml b/.idea/json2java.xml
new file mode 100644
index 0000000..db29bca
--- /dev/null
+++ b/.idea/json2java.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..703e5d4
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml
new file mode 100644
index 0000000..7f68460
--- /dev/null
+++ b/.idea/runConfigurations.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/.gitignore b/app/.gitignore
new file mode 100644
index 0000000..796b96d
--- /dev/null
+++ b/app/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/app/build.gradle b/app/build.gradle
new file mode 100644
index 0000000..24bbc9d
--- /dev/null
+++ b/app/build.gradle
@@ -0,0 +1,44 @@
+import java.text.SimpleDateFormat
+
+apply plugin: 'com.android.application'
+
+android {
+ compileSdkVersion 28
+ defaultConfig {
+ applicationId "ma.mhy.sqliteeditorroot"
+ minSdkVersion 15
+ targetSdkVersion 28
+ versionCode getMyVersionCode()
+ versionName getMyVersionName()
+ testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ implementation 'com.android.support:appcompat-v7:28.0.0'
+ implementation 'com.android.support.constraint:constraint-layout:1.1.3'
+ testImplementation 'junit:junit:4.12'
+ androidTestImplementation 'com.android.support.test:runner:1.0.2'
+ androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
+ implementation 'com.github.huangyanbin:SmartTable:2.2.0'
+// implementation 'androidx.annotation:annotation:1.0.0'
+}
+
+static def getMyVersionCode() {
+ return Integer.parseInt(new SimpleDateFormat("yyMMdd").format(new Date()))
+}
+
+static def getMyVersionName() {
+ return "1.0.6." + "git describe --always".execute().getText().trim()
+}
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
new file mode 100644
index 0000000..f1b4245
--- /dev/null
+++ b/app/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
diff --git a/app/src/androidTest/java/ma/mhy/sqliteeditorroot/ExampleInstrumentedTest.java b/app/src/androidTest/java/ma/mhy/sqliteeditorroot/ExampleInstrumentedTest.java
new file mode 100644
index 0000000..739e0ae
--- /dev/null
+++ b/app/src/androidTest/java/ma/mhy/sqliteeditorroot/ExampleInstrumentedTest.java
@@ -0,0 +1,26 @@
+package ma.mhy.sqliteeditorroot;
+
+import android.content.Context;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * @see Testing documentation
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+ @Test
+ public void useAppContext() {
+ // Context of the app under test.
+ Context appContext = InstrumentationRegistry.getTargetContext();
+
+ assertEquals("ma.mhy.sqliteeditorroot", appContext.getPackageName());
+ }
+}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..7f8d3ae
--- /dev/null
+++ b/app/src/main/AndroidManifest.xml
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/ma/mhy/sqliteeditorroot/App.java b/app/src/main/java/ma/mhy/sqliteeditorroot/App.java
new file mode 100644
index 0000000..33d0a66
--- /dev/null
+++ b/app/src/main/java/ma/mhy/sqliteeditorroot/App.java
@@ -0,0 +1,14 @@
+package ma.mhy.sqliteeditorroot;
+
+import android.app.Application;
+
+
+import ma.mhy.sqliteeditorroot.util.Crashlytics;
+
+public class App extends Application {
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ Thread.setDefaultUncaughtExceptionHandler(new Crashlytics(this));
+ }
+}
diff --git a/app/src/main/java/ma/mhy/sqliteeditorroot/C.java b/app/src/main/java/ma/mhy/sqliteeditorroot/C.java
new file mode 100644
index 0000000..36c344b
--- /dev/null
+++ b/app/src/main/java/ma/mhy/sqliteeditorroot/C.java
@@ -0,0 +1,6 @@
+package ma.mhy.sqliteeditorroot;
+
+public class C {
+ public static final String EXTRA_DATABASE_PATH = ".extra.EXTRA_DATABASE_PATH";
+ public static final String EXTRA_TABLE_NAME = ".extra.EXTRA_TABLE_NAME";
+}
diff --git a/app/src/main/java/ma/mhy/sqliteeditorroot/bean/Cell.java b/app/src/main/java/ma/mhy/sqliteeditorroot/bean/Cell.java
new file mode 100644
index 0000000..2a8657c
--- /dev/null
+++ b/app/src/main/java/ma/mhy/sqliteeditorroot/bean/Cell.java
@@ -0,0 +1,15 @@
+package ma.mhy.sqliteeditorroot.bean;
+
+public class Cell {
+ public int col;
+ public int row;
+ public String oldVal;
+ public String newVal;
+
+ public Cell(int col, int row, String oldVal, String newVal) {
+ this.col = col;
+ this.row = row;
+ this.oldVal = oldVal;
+ this.newVal = newVal;
+ }
+}
diff --git a/app/src/main/java/ma/mhy/sqliteeditorroot/ui/HelloActivity.java b/app/src/main/java/ma/mhy/sqliteeditorroot/ui/HelloActivity.java
new file mode 100644
index 0000000..48915c5
--- /dev/null
+++ b/app/src/main/java/ma/mhy/sqliteeditorroot/ui/HelloActivity.java
@@ -0,0 +1,194 @@
+package ma.mhy.sqliteeditorroot.ui;
+
+
+import android.app.AlertDialog;
+import android.app.ProgressDialog;
+import android.content.ComponentName;
+
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.net.Uri;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v7.app.AppCompatActivity;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.widget.Toast;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.IOException;
+
+import ma.mhy.sqliteeditorroot.R;
+import ma.mhy.sqliteeditorroot.util.RequstRoot;
+
+//import androidx.annotation.Nullable;
+
+
+public class HelloActivity extends AppCompatActivity {
+ ProgressDialog progress_dialog;
+String tag="mhy";
+//String apkRoot = "chmod 777 " + getPackageCodePath();//getPackageCodePath()来获得当前应用程序对应的 apk 文件的路径
+
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_about);
+ //当前应用的代码执行目录
+ // upgradeRootPermission(getPackageCodePath());
+ // boolean b = RootCommand(apkRoot);//给这个路径777权限
+ // Log.v(tag,"获取Root权限:"+b);
+ //检测设备是否root 并获取root权限
+ get_root();
+
+ findViewById(R.id.action_ok).setOnClickListener(v ->
+ new AlertDialog.Builder(HelloActivity.this)
+ .setCancelable(false)
+ .setMessage(R.string.app_notice)
+ .setPositiveButton(R.string.action_know, (dialog, which) -> finish())
+ .create()
+ .show());
+ }
+
+ // 判断是否具有ROOT权限
+ public static boolean is_root() {
+
+ boolean res = false;
+
+ try {
+ if ((!new File("/system/bin/su").exists()) &&
+ (!new File("/system/xbin/su").exists())) {
+ res = false;
+ } else {
+ res = true;
+ }
+ ;
+ } catch (Exception e) {
+
+ }
+ return res;
+ }
+
+ // 获取ROOT权限.获取Android的ROOT权限其实很简单,只要在Runtime下执行命令"su"就可以了。
+ public void get_root() {
+
+ if (is_root()) {
+ Toast.makeText(this, "请授予ROOT权限!", Toast.LENGTH_LONG).show();
+
+ //请求root权限
+ String apkRoot="chmod 777 "+getPackageCodePath();
+ RequstRoot.RootCommand(apkRoot);//
+
+ } else {
+ try {
+ progress_dialog = ProgressDialog.show(this,
+ "ROOT", "正在获取ROOT权限...", true, false);
+ Runtime.getRuntime().exec("su");
+ } catch (Exception e) {
+ Toast.makeText(this, "获取ROOT权限时出错!", Toast.LENGTH_LONG).show();
+ }
+ }
+ }
+ /**
+ * 应用程序运行命令获取 Root权限,设备必须已破解(获得ROOT权限)
+ *
+ * @return 应用程序是/否获取Root权限
+ */
+ public static boolean upgradeRootPermission(String pkgCodePath) {
+ Process process = null;
+ DataOutputStream os = null;
+ try {
+ String cmd="chmod 777 " + pkgCodePath;
+ process = Runtime.getRuntime().exec("su"); //切换到root帐号
+ os = new DataOutputStream(process.getOutputStream());
+ os.writeBytes(cmd + "\n");
+ os.writeBytes("exit\n");
+ os.flush();
+ process.waitFor();
+ } catch (Exception e) {
+ return false;
+ } finally {
+ try {
+ if (os != null) {
+ os.close();
+ }
+ process.destroy();
+ } catch (Exception e) {
+ }
+ }
+ return true;
+ }
+ /**
+ * 应用程序运行命令获取 Root权限,设备必须已破解(获得ROOT权限)
+ *
+ * @param command 命令:String apkRoot="chmod 777 "+getPackageCodePath(); RootCommand(apkRoot);
+ * @return 应用程序是/否获取Root权限
+ */
+// public boolean RootCommand(String command) {
+// Process process = null;
+// DataOutputStream os = null;
+// DataInputStream is = null;
+// try {
+// process = Runtime.getRuntime().exec("su");
+// os = new DataOutputStream(process.getOutputStream());
+// os.writeBytes(command + "\n");
+// os.writeBytes("exit\n");
+// os.flush();
+// int aa = process.waitFor();
+// Log.w(tag,"waitFor():"+aa);
+// is = new DataInputStream(process.getInputStream());
+// byte[] buffer = new byte[is.available()];
+// Log.d(tag,"大小"+buffer.length);
+// is.read(buffer);
+// String out = new String(buffer);
+// Log.e(tag,"返回:"+out);
+// } catch (Exception e) {
+// e.printStackTrace();
+// Log.e(tag,tag + "205:\n" + e);
+// return false;
+// } finally {
+// try {
+// if (os != null) {
+// os.close();
+// }
+// if (is != null) {
+// is.close();
+// }
+// } catch (IOException e) {
+// e.printStackTrace();
+// Log.e(tag,tag + "217:\n" + e);
+// }
+// process.destroy();
+// }
+// Log.d(tag,tag + "222 SUCCESS");
+// return true;
+// }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.hello, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ startActivity(new Intent(Intent.ACTION_VIEW)
+ .setData(Uri.parse("https://github.com/Yaerin/SQLiteEditor"))
+ .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
+ return true;
+ }
+
+ @Override
+ protected void onStop() {
+ disableSelf();
+ super.onStop();
+ }
+
+ private void disableSelf() {
+ getPackageManager().setComponentEnabledSetting(
+ new ComponentName(this, this.getClass()),
+ PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);
+ }
+}
diff --git a/app/src/main/java/ma/mhy/sqliteeditorroot/ui/MainActivity.java b/app/src/main/java/ma/mhy/sqliteeditorroot/ui/MainActivity.java
new file mode 100644
index 0000000..50d7d06
--- /dev/null
+++ b/app/src/main/java/ma/mhy/sqliteeditorroot/ui/MainActivity.java
@@ -0,0 +1,208 @@
+package ma.mhy.sqliteeditorroot.ui;
+
+import android.Manifest;
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.Intent;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.net.Uri;
+import android.os.Build;
+import android.os.Bundle;
+
+import android.support.v7.app.AppCompatActivity;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.ArrayAdapter;
+import android.widget.EditText;
+import android.widget.ListView;
+import android.widget.PopupMenu;
+import android.widget.Toast;
+
+import ma.mhy.sqliteeditorroot.C;
+
+import java.io.File;
+import java.io.IOException;
+import java.text.Collator;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Locale;
+
+//import androidx.annotation.NonNull;
+//import androidx.annotation.Nullable;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import ma.mhy.sqliteeditorroot.R;
+
+public class MainActivity extends AppCompatActivity implements PopupMenu.OnMenuItemClickListener {
+
+ private String mPath;
+ private SQLiteDatabase mDatabase;
+ private List mTableNames;
+ private String mTableName;
+
+ private ListView mTables;
+ private ArrayAdapter mAdapter;
+
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ mTables = findViewById(R.id.table);
+
+ Uri uri = getIntent().getData();
+ if (uri == null || uri.getScheme() == null || uri.getPath() == null) {
+ Toast.makeText(this, getIntent().toString(), Toast.LENGTH_LONG).show();
+ return;
+ }
+ //权限申请
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
+ mPath = getFileForUri(uri).getPath();
+ } else {
+ mPath = uri.getPath();
+ }
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ requestPermissions(new String[]{
+ Manifest.permission.READ_EXTERNAL_STORAGE,
+ Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1000);
+ } else {
+ main();
+ }
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.action_exec: {
+ View view = View.inflate(MainActivity.this, R.layout.dialog_edit, null);
+ EditText editText = view.findViewById(R.id.edit_text);
+ editText.setHint(R.string.hint_sql);
+ new AlertDialog.Builder(this)
+ .setCancelable(false)
+ .setTitle(R.string.action_exec_sql)
+ .setView(view)
+ .setNegativeButton(R.string.action_cancel, (dialog, which) -> dialog.dismiss())
+ .setPositiveButton(R.string.action_ok, (dialog, which) -> {
+ try {
+ mDatabase.execSQL(editText.getText().toString());
+ Toast.makeText(this, R.string.message_success, Toast.LENGTH_SHORT).show();
+ refresh();
+ } catch (Exception e) {
+ Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
+ }
+ })
+ .create()
+ .show();
+ break;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
+ main();
+ }
+
+ @Override
+ public boolean onMenuItemClick(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.action_delete: {
+ new AlertDialog.Builder(this)
+ .setTitle(R.string.title_confirm)
+ .setMessage(R.string.message_irreversible)
+ .setPositiveButton(R.string.action_ok, (dialog, which) -> {
+ mDatabase.execSQL("DROP TABLE \"" + mTableName + "\"");
+ refresh();
+ })
+ .create()
+ .show();
+ break;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ protected void onDestroy() {
+ mDatabase.close();
+ super.onDestroy();
+ }
+
+ private void main() {
+ try {
+ openDatabase();
+ mTableNames = getTableNames();
+ initView();
+ } catch (Exception e) {
+ Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show();
+ }
+ }
+
+ private void refresh() {
+ mTableNames.clear();
+ mTableNames.addAll(getTableNames());
+ mAdapter.notifyDataSetChanged();
+ }
+
+ private void initView() {
+ mTables.setAdapter(mAdapter = new ArrayAdapter<>(
+ this, R.layout.item_table, R.id.table_name, mTableNames));
+ mTables.setOnItemClickListener((parent, view, position, id) ->
+ startActivity(new Intent(MainActivity.this, TableActivity.class)
+ .putExtra(C.EXTRA_DATABASE_PATH, mPath)
+ .putExtra(C.EXTRA_TABLE_NAME, mTableNames.get(position))));
+ mTables.setOnItemLongClickListener((parent, view, position, id) -> {
+ mTableName = mTableNames.get(position);
+ PopupMenu popup = new PopupMenu(MainActivity.this, view);
+ popup.getMenuInflater().inflate(R.menu.main_popup, popup.getMenu());
+ popup.setOnMenuItemClickListener(this);
+ popup.show();
+ return true;
+ });
+ }
+
+ private void openDatabase() {
+ String[] arr = mPath.split("/");
+ setTitle("`" + arr[arr.length - 1].replaceAll("\\.db$", "") + "`");
+ mDatabase = SQLiteDatabase.openDatabase(mPath, null, SQLiteDatabase.OPEN_READWRITE, sqLiteDatabase -> {
+ });
+ }
+
+ private List getTableNames() {
+ List list = new ArrayList<>();
+ Cursor cursor = mDatabase.rawQuery("SELECT name FROM sqlite_master WHERE type = 'table' ORDER BY name", null);
+ while (cursor.moveToNext()) {
+ list.add(cursor.getString(0));
+ }
+ cursor.close();
+ Collections.sort(list, Collator.getInstance(Locale.getDefault()));
+ return list;
+ }
+
+ private File getFileForUri(Uri uri) {
+ String path = uri.getEncodedPath();
+
+ assert path != null;
+ final int splitIndex = path.indexOf('/', 1);
+ path = Uri.decode(path.substring(splitIndex + 1));
+ File file = new File("/storage", path);
+ try {
+ file = file.getCanonicalFile();
+ } catch (IOException e) {
+ throw new IllegalArgumentException("Failed to resolve canonical path for " + file);
+ }
+
+ return file;
+ }
+
+}
diff --git a/app/src/main/java/ma/mhy/sqliteeditorroot/ui/TableActivity.java b/app/src/main/java/ma/mhy/sqliteeditorroot/ui/TableActivity.java
new file mode 100644
index 0000000..ff71fa1
--- /dev/null
+++ b/app/src/main/java/ma/mhy/sqliteeditorroot/ui/TableActivity.java
@@ -0,0 +1,343 @@
+package ma.mhy.sqliteeditorroot.ui;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.graphics.Rect;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v7.app.AppCompatActivity;
+import android.text.TextUtils;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.EditText;
+import android.widget.ProgressBar;
+import android.widget.Toast;
+
+import com.bin.david.form.core.SmartTable;
+import com.bin.david.form.data.CellInfo;
+import com.bin.david.form.data.column.Column;
+import com.bin.david.form.data.format.bg.ICellBackgroundFormat;
+import com.bin.david.form.data.format.draw.TextDrawFormat;
+import com.bin.david.form.data.table.ArrayTableData;
+import com.bin.david.form.data.table.TableData;
+import ma.mhy.sqliteeditorroot.C;
+import ma.mhy.sqliteeditorroot.R;
+import ma.mhy.sqliteeditorroot.bean.Cell;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Pattern;
+
+//import androidx.annotation.Nullable;
+
+public class TableActivity extends AppCompatActivity {
+
+ private SQLiteDatabase mDatabase;
+ private String mTableName;
+ private String[] mColumnNames;
+ private List mUndoList = new ArrayList<>();
+ private List mRedoList = new ArrayList<>();
+ private List mUndoVList = new ArrayList<>();
+ private List mRedoVList = new ArrayList<>();
+
+ private ProgressBar mProgressBar;
+ private SmartTable mTable;
+ private ArrayTableData mTableData;
+
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_table);
+ mProgressBar = findViewById(R.id.progress);
+ mTable = findViewById(R.id.table);
+ mTable.setZoom(true, 2.0f, 0.5f);
+ mTable.getConfig()
+ .setMinTableWidth(mTable.getWidth())
+ .setShowTableTitle(false)
+ .setShowXSequence(false)
+ .setShowYSequence(false)
+ .setFixedTitle(true)
+ .setContentCellBackgroundFormat(new ICellBackgroundFormat() {
+ @Override
+ public void drawBackground(Canvas canvas, Rect rect,
+ CellInfo cellInfo, Paint paint) {
+ if (cellInfo.row % 2 == 0) {
+ paint.setColor(0xFFFAFAFA);
+ canvas.drawRect(rect, paint);
+ }
+ for (Cell cell : mUndoVList) {
+ if (cell.col == cellInfo.col && cell.row == cellInfo.row) {
+ paint.setColor(0xFFFFE4B5);
+ canvas.drawRect(rect, paint);
+ }
+ }
+ }
+
+ @Override
+ public int getTextColor(CellInfo cellInfo) {
+ return 0;
+ }
+ });
+
+ String path = getIntent().getStringExtra(C.EXTRA_DATABASE_PATH);
+ mDatabase = SQLiteDatabase.openDatabase(path, null, SQLiteDatabase.OPEN_READWRITE);
+ mTableName = getIntent().getStringExtra(C.EXTRA_TABLE_NAME);
+
+ String[] arr = path.split("/");
+ setTitle("`" + arr[arr.length - 1].replaceAll("\\.db$", "") + "`." + mTableName);
+
+ init();
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.table, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onPrepareOptionsMenu(Menu menu) {
+ boolean enabledUndo = mUndoList.size() > 0;
+ boolean enabledRedo = mRedoList.size() > 0;
+ boolean enabledSave = mUndoList.size() > 0;
+
+ MenuItem undo = menu.findItem(R.id.action_undo);
+ MenuItem redo = menu.findItem(R.id.action_redo);
+ MenuItem save = menu.findItem(R.id.action_save);
+
+ undo.setEnabled(enabledUndo);
+ undo.setIcon(enabledUndo ? R.drawable.ic_undo_white_24dp : R.drawable.ic_undo_gray_24dp);
+ redo.setEnabled(enabledRedo);
+ redo.setIcon(enabledRedo ? R.drawable.ic_redo_white_24dp : R.drawable.ic_redo_gray_24dp);
+ save.setEnabled(enabledSave);
+ save.setIcon(enabledSave ? R.drawable.ic_save_white_24dp : R.drawable.ic_save_gray_24dp);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.action_undo: {
+ if (mUndoList.size() > 0 && mUndoVList.size() > 0) {
+ String s = mUndoList.get(mUndoList.size() - 1);
+ mRedoList.add(s);
+ mUndoList.remove(s);
+ Cell c = mUndoVList.get(mUndoVList.size() - 1);
+ mRedoVList.add(c);
+ mUndoVList.remove(c);
+ mTableData.getData()[c.col][c.row] = c.oldVal;
+ mTable.invalidate();
+ }
+ invalidateOptionsMenu();
+ break;
+ }
+
+ case R.id.action_redo: {
+ if (mRedoList.size() > 0) {
+ String s = mRedoList.get(mRedoList.size() - 1);
+ mUndoList.add(s);
+ mRedoList.remove(s);
+ Cell c = mRedoVList.get(mRedoVList.size() - 1);
+ mUndoVList.add(c);
+ mRedoVList.remove(c);
+ mTableData.getData()[c.col][c.row] = c.newVal;
+ mTable.invalidate();
+ }
+ invalidateOptionsMenu();
+ break;
+ }
+
+ case R.id.action_save: {
+ try {
+ execSQLs();
+ } catch (Exception e) {
+ Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show();
+ }
+ break;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ protected void onDestroy() {
+ mDatabase.close();
+ super.onDestroy();
+ }
+
+ private void execSQLs() {
+ for (String sql : mUndoList) {
+ mDatabase.execSQL(sql);
+ }
+ mUndoList.clear();
+ mRedoList.clear();
+ mUndoVList.clear();
+ mRedoVList.clear();
+ mTable.invalidate();
+ invalidateOptionsMenu();
+ }
+
+ private String[] getColumnNames() {
+ Cursor c = mDatabase.rawQuery(
+ "PRAGMA table_info(\"" + mTableName + "\")", null);
+ List list = new ArrayList<>();
+ while (c.moveToNext()) {
+ list.add(c.getString(c.getColumnIndex("name")));
+ }
+ c.close();
+ return list.toArray(new String[0]);
+ }
+
+ private String[][] buildArray() {
+ Cursor cursor = mDatabase.rawQuery(
+ "SELECT * FROM \"" + mTableName + "\"", null);
+ Cursor c = mDatabase.rawQuery(
+ "PRAGMA table_info(\"" + mTableName + "\")", null);
+
+ if (cursor.getCount() == 0) {
+ cursor.close();
+ c.close();
+ return null;
+ }
+
+ String[][] data = new String[cursor.getColumnCount()][cursor.getCount()];
+ for (int i = 0; i < cursor.getColumnCount(); i++) {
+ c.moveToPosition(i);
+ for (int j = 0; j < cursor.getCount(); j++) {
+ cursor.moveToPosition(j);
+ if (c.getString(c.getColumnIndex("type")).equals("BLOB")) {
+ data[i][j] = "[BLOB]";
+ } else {
+ data[i][j] = cursor.getString(cursor.getColumnIndex(mColumnNames[i]));
+ }
+ }
+ }
+
+ cursor.close();
+ c.close();
+ return data;
+ }
+
+ @Nullable
+ private String getPrimaryKey(String sql) {
+ String primaryKey = null;
+ int start = sql.indexOf("(") + 1;
+ int end = sql.length() - new StringBuilder(sql).reverse().toString().indexOf(")") - 1;
+ sql = sql.substring(start, end);
+ String[] arr = sql.replaceAll("\\s+", " ").split(",");
+ for (String s : arr) {
+ s = s.trim();
+ if (Pattern.compile(".*PRIMARY\\s+KEY.*",
+ Pattern.CASE_INSENSITIVE).matcher(s).matches()) {
+ primaryKey = s.split("\\s+")[0].replaceAll("\"", "");
+ }
+ }
+ return primaryKey;
+ }
+
+ private String buildSQL(int col, int row, String name, String newValue) {
+ Cursor cursor = mDatabase.rawQuery(
+ "SELECT sql FROM sqlite_master WHERE name=\"" + mTableName + "\"", null);
+ cursor.moveToPosition(0);
+ String sql = cursor.getString(cursor.getColumnIndex("sql"));
+ cursor.close();
+
+ String primaryKey = getPrimaryKey(sql);
+
+ if (primaryKey == null) {
+ Toast.makeText(this, R.string.err_primary_key, Toast.LENGTH_LONG).show();
+ return null;
+ }
+
+ Cursor c = mDatabase.rawQuery(
+ String.format("SELECT \"%s\",\"%s\" FROM \"%s\"", primaryKey, name, mTableName), null);
+ c.moveToPosition(row);
+ String key = c.getString(c.getColumnIndex(primaryKey));
+ String value = c.getString(c.getColumnIndex(name));
+ c.close();
+ if (value.equals(newValue)) {
+ return null;
+ } else {
+ mTableData.getData()[col][row] = newValue;
+ mTable.invalidate();
+ mUndoVList.add(new Cell(col, row, value, newValue));
+ if (!mRedoVList.isEmpty()) {
+ mRedoVList.clear();
+ }
+ return "UPDATE " + mTableName +
+ " SET " + name + "=\"" + newValue + "\"" +
+ " WHERE " + primaryKey + "=\"" + key + "\"";
+ }
+ }
+
+ private void init() {
+ mProgressBar.setVisibility(View.VISIBLE);
+ mColumnNames = getColumnNames();
+ new Thread(() -> {
+ final String[][][] array = {buildArray()};
+ runOnUiThread(() -> {
+ if (array[0] == null) {
+ array[0] = new String[mColumnNames.length][0];
+ }
+ mTableData =
+ ArrayTableData.create(null, mColumnNames, array[0], new TextDrawFormat<>());
+ mTableData.setOnItemClickListener(new OnItemClickListener());
+ mTable.setTableData(mTableData);
+ mProgressBar.setVisibility(View.GONE);
+ });
+ }).start();
+ }
+
+ private class OnItemClickListener implements TableData.OnItemClickListener {
+
+ @Override
+ public void onClick(Column column, String value, Object o, int col, int row) {
+ Cursor cursor = mDatabase.rawQuery(
+ "PRAGMA table_info(\"" + mTableName + "\")", null);
+ cursor.moveToPosition(col);
+ String name = cursor.getString(cursor.getColumnIndex("name"));
+ String type = cursor.getString(cursor.getColumnIndex("type"));
+ boolean notNull = cursor.getInt(cursor.getColumnIndex("notnull")) == 1;
+ cursor.close();
+
+ if (type.equals("BLOB")) {
+ Toast.makeText(TableActivity.this, R.string.err_blob_data, Toast.LENGTH_SHORT).show();
+ return;
+ }
+
+ View view = View.inflate(TableActivity.this, R.layout.dialog_edit, null);
+ EditText editText = view.findViewById(R.id.edit_text);
+ editText.setText(value);
+ editText.requestFocus();
+ editText.selectAll();
+ new AlertDialog.Builder(TableActivity.this)
+ .setTitle(getString(R.string.title_edit,
+ name, type + (notNull ? " NOT NULL" : "")))
+ .setView(view)
+ .setNegativeButton(R.string.action_cancel, (dialog, which) -> dialog.dismiss())
+ .setPositiveButton(R.string.action_ok, (dialog, which) -> {
+ String newValue = editText.getText().toString();
+ if (TextUtils.isEmpty(newValue) && notNull) {
+ Toast.makeText(TableActivity.this,
+ "NOT NULL", Toast.LENGTH_SHORT).show();
+ } else if (!newValue.equals(value)) {
+ String sql = buildSQL(col, row, name, newValue);
+ if (sql != null) {
+ mUndoList.add(sql);
+ if (!mRedoList.isEmpty()) {
+ mRedoList.clear();
+ }
+ invalidateOptionsMenu();
+ }
+ }
+ })
+ .create()
+ .show();
+ }
+ }
+}
diff --git a/app/src/main/java/ma/mhy/sqliteeditorroot/util/Crashlytics.java b/app/src/main/java/ma/mhy/sqliteeditorroot/util/Crashlytics.java
new file mode 100644
index 0000000..3e055e3
--- /dev/null
+++ b/app/src/main/java/ma/mhy/sqliteeditorroot/util/Crashlytics.java
@@ -0,0 +1,104 @@
+package ma.mhy.sqliteeditorroot.util;
+
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.os.Build;
+import android.os.Process;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+
+public class Crashlytics implements Thread.UncaughtExceptionHandler {
+
+ private Context mContext;
+
+ public Crashlytics(Context context) {
+ this.mContext = context;
+ }
+
+ @Override
+ public void uncaughtException(Thread t, Throwable e) {
+ e.printStackTrace();
+ String crashTime =
+ new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.getDefault())
+ .format(new Date());
+ String env =
+ "########RuntimeEnviormentInormation#######\n" +
+ "crashTime = " + crashTime + "\n" +
+ "model = " + Build.MODEL + "\n" +
+ "android = " + Build.VERSION.RELEASE + "(" + Build.VERSION.SDK_INT + ")\n" +
+ "brand = " + Build.BRAND + "\n" +
+ "manufacturer = " + Build.MANUFACTURER + "\n" +
+ "board = " + Build.BOARD + "\n" +
+ "hardware = " + Build.HARDWARE + "\n" +
+ "device = " + Build.DEVICE + "\n" +
+ "version = " + getVersionName() + "(" + getVersionCode() + ")\n" +
+ "supportAbis = " + getSupportAbis() + "\n" +
+ "display = " + Build.DISPLAY + "\n";
+ Writer writer = new StringWriter();
+ PrintWriter printWriter = new PrintWriter(writer);
+ e.printStackTrace(printWriter);
+ Throwable cause = e.getCause();
+ while (cause != null) {
+ cause.printStackTrace(printWriter);
+ cause = cause.getCause();
+ }
+ printWriter.close();
+ String stack = "############ForceCloseCrashLog############\n" + writer.toString();
+ String message = env + stack;
+ try {
+ String name = "error_log_" + crashTime + ".log";
+ FileOutputStream fos =
+ new FileOutputStream(new File(mContext.getExternalFilesDir("logs"), name));
+ fos.write(message.getBytes());
+ fos.close();
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+
+ Process.killProcess(Process.myPid());
+ System.exit(1);
+ }
+
+ private String getVersionName() {
+ String versionName = "unknown";
+ try {
+ versionName = mContext.getPackageManager()
+ .getPackageInfo(mContext.getPackageName(), 0).versionName;
+ } catch (PackageManager.NameNotFoundException e) {
+ e.printStackTrace();
+ }
+ return versionName;
+ }
+
+ private int getVersionCode() {
+ int versionCode = -1;
+ try {
+ versionCode = mContext.getPackageManager()
+ .getPackageInfo(mContext.getPackageName(), 0).versionCode;
+ } catch (PackageManager.NameNotFoundException e) {
+ e.printStackTrace();
+ }
+ return versionCode;
+ }
+
+ private String getSupportAbis() {
+ String[] abis = Build.SUPPORTED_ABIS;
+ StringBuilder abi = new StringBuilder();
+ for (int i = 0; i < abis.length; i++) {
+ if (i == 0) {
+ abi.append(abis[i]);
+ } else {
+ abi.append(" & ").append(abis[i]);
+ }
+ }
+ return abi.toString();
+ }
+}
diff --git a/app/src/main/java/ma/mhy/sqliteeditorroot/util/RequstRoot.java b/app/src/main/java/ma/mhy/sqliteeditorroot/util/RequstRoot.java
new file mode 100644
index 0000000..31a0740
--- /dev/null
+++ b/app/src/main/java/ma/mhy/sqliteeditorroot/util/RequstRoot.java
@@ -0,0 +1,77 @@
+package ma.mhy.sqliteeditorroot.util;
+
+
+import java.io.DataOutputStream;
+
+
+import android.app.Activity;
+
+import android.util.Log;
+
+
+public class RequstRoot extends Activity {
+
+
+ /**
+ *
+ * 应用程序运行命令获取 Root权限,设备必须已破解(获得ROOT权限)
+ *
+ *
+ * @param command 命令:String apkRoot="chmod 777 "+getPackageCodePath(); RootCommand(apkRoot);
+ *
+ * @return 应用程序是/否获取Root权限
+ *
+ */
+
+ public static boolean RootCommand(String command) {
+
+ Process process = null;
+
+ DataOutputStream os = null;
+
+ try {
+
+ process = Runtime.getRuntime().exec("su");
+
+ os = new DataOutputStream(process.getOutputStream());
+
+ os.writeBytes(command + "\n");
+
+ os.writeBytes("exit\n");
+
+ os.flush();
+
+ process.waitFor();
+
+ } catch (Exception e) {
+
+ Log.d("*** mhy ***", "ROOT REE" + e.getMessage());
+
+ return false;
+
+ } finally {
+
+ try {
+
+ if (os != null) {
+
+ os.close();
+
+ }
+
+ process.destroy();
+
+ } catch (Exception e) {
+
+ }
+
+ }
+
+ Log.d("*** mhy ***", "Root SUC ");
+
+ return true;
+
+ }
+
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/ma/mhy/sqliteeditorroot/util/RootGo.java b/app/src/main/java/ma/mhy/sqliteeditorroot/util/RootGo.java
new file mode 100644
index 0000000..41909ca
--- /dev/null
+++ b/app/src/main/java/ma/mhy/sqliteeditorroot/util/RootGo.java
@@ -0,0 +1,54 @@
+package ma.mhy.sqliteeditorroot.util;
+
+import android.app.ProgressDialog;
+import android.content.Context;
+import android.widget.Toast;
+
+import java.io.File;
+
+public class RootGo {
+ private ProgressDialog progress_dialog;
+
+ private Context mCtx ;
+ /***
+ * 其中is_root()判断是否已经具有了ROOT权限。
+ * 只要/system/bin/su、/system/xbin/su这两个文件中有一个存在,
+ * 就表明已经具有ROOT权限,如果两个都不存在,则不具有ROOT权限。
+ * @return
+ */
+ // 判断是否具有ROOT权限
+ public static boolean is_root() {
+
+ boolean res = false;
+
+ try {
+ if ((!new File("/system/bin/su").exists()) &&
+ (!new File("/system/xbin/su").exists())) {
+ res = false;
+ } else {
+ res = true;
+ }
+ ;
+ } catch (Exception e) {
+
+ }
+ return res;
+ }
+
+ // 获取ROOT权限.获取Android的ROOT权限其实很简单,只要在Runtime下执行命令"su"就可以了。
+ public void get_root() {
+
+ if (is_root()) {
+ Toast.makeText(mCtx, "已经具有ROOT权限!", Toast.LENGTH_LONG).show();
+ } else {
+ try {
+ progress_dialog = ProgressDialog.show(mCtx,
+ "ROOT", "正在获取ROOT权限...", true, false);
+ Runtime.getRuntime().exec("su");
+ } catch (Exception e) {
+ Toast.makeText(mCtx, "获取ROOT权限时出错!", Toast.LENGTH_LONG).show();
+ }
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
new file mode 100644
index 0000000..1f6bb29
--- /dev/null
+++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/ic_console_line_white_24dp.xml b/app/src/main/res/drawable/ic_console_line_white_24dp.xml
new file mode 100644
index 0000000..d47874e
--- /dev/null
+++ b/app/src/main/res/drawable/ic_console_line_white_24dp.xml
@@ -0,0 +1,12 @@
+
+
+
diff --git a/app/src/main/res/drawable/ic_github_circle_white_24dp.xml b/app/src/main/res/drawable/ic_github_circle_white_24dp.xml
new file mode 100644
index 0000000..27d2cf3
--- /dev/null
+++ b/app/src/main/res/drawable/ic_github_circle_white_24dp.xml
@@ -0,0 +1,10 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml
new file mode 100644
index 0000000..0d025f9
--- /dev/null
+++ b/app/src/main/res/drawable/ic_launcher_background.xml
@@ -0,0 +1,170 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/ic_redo_gray_24dp.xml b/app/src/main/res/drawable/ic_redo_gray_24dp.xml
new file mode 100644
index 0000000..bd53d3a
--- /dev/null
+++ b/app/src/main/res/drawable/ic_redo_gray_24dp.xml
@@ -0,0 +1,10 @@
+
+
+
diff --git a/app/src/main/res/drawable/ic_redo_white_24dp.xml b/app/src/main/res/drawable/ic_redo_white_24dp.xml
new file mode 100644
index 0000000..1c4e6c0
--- /dev/null
+++ b/app/src/main/res/drawable/ic_redo_white_24dp.xml
@@ -0,0 +1,10 @@
+
+
+
diff --git a/app/src/main/res/drawable/ic_save_gray_24dp.xml b/app/src/main/res/drawable/ic_save_gray_24dp.xml
new file mode 100644
index 0000000..f00dda8
--- /dev/null
+++ b/app/src/main/res/drawable/ic_save_gray_24dp.xml
@@ -0,0 +1,10 @@
+
+
+
diff --git a/app/src/main/res/drawable/ic_save_white_24dp.xml b/app/src/main/res/drawable/ic_save_white_24dp.xml
new file mode 100644
index 0000000..b32b114
--- /dev/null
+++ b/app/src/main/res/drawable/ic_save_white_24dp.xml
@@ -0,0 +1,10 @@
+
+
+
diff --git a/app/src/main/res/drawable/ic_undo_gray_24dp.xml b/app/src/main/res/drawable/ic_undo_gray_24dp.xml
new file mode 100644
index 0000000..a204ec7
--- /dev/null
+++ b/app/src/main/res/drawable/ic_undo_gray_24dp.xml
@@ -0,0 +1,10 @@
+
+
+
diff --git a/app/src/main/res/drawable/ic_undo_white_24dp.xml b/app/src/main/res/drawable/ic_undo_white_24dp.xml
new file mode 100644
index 0000000..401b08b
--- /dev/null
+++ b/app/src/main/res/drawable/ic_undo_white_24dp.xml
@@ -0,0 +1,10 @@
+
+
+
diff --git a/app/src/main/res/drawable/popup_background.xml b/app/src/main/res/drawable/popup_background.xml
new file mode 100644
index 0000000..e2588c6
--- /dev/null
+++ b/app/src/main/res/drawable/popup_background.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml
new file mode 100644
index 0000000..5ba0e29
--- /dev/null
+++ b/app/src/main/res/layout/activity_about.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
new file mode 100644
index 0000000..cab4866
--- /dev/null
+++ b/app/src/main/res/layout/activity_main.xml
@@ -0,0 +1,5 @@
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_table.xml b/app/src/main/res/layout/activity_table.xml
new file mode 100644
index 0000000..9926f09
--- /dev/null
+++ b/app/src/main/res/layout/activity_table.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/dialog_edit.xml b/app/src/main/res/layout/dialog_edit.xml
new file mode 100644
index 0000000..0cc3980
--- /dev/null
+++ b/app/src/main/res/layout/dialog_edit.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/item_table.xml b/app/src/main/res/layout/item_table.xml
new file mode 100644
index 0000000..39e7a69
--- /dev/null
+++ b/app/src/main/res/layout/item_table.xml
@@ -0,0 +1,9 @@
+
+
\ No newline at end of file
diff --git a/app/src/main/res/menu/hello.xml b/app/src/main/res/menu/hello.xml
new file mode 100644
index 0000000..77e3bce
--- /dev/null
+++ b/app/src/main/res/menu/hello.xml
@@ -0,0 +1,8 @@
+
+
\ No newline at end of file
diff --git a/app/src/main/res/menu/main.xml b/app/src/main/res/menu/main.xml
new file mode 100644
index 0000000..09693e1
--- /dev/null
+++ b/app/src/main/res/menu/main.xml
@@ -0,0 +1,13 @@
+
+
\ No newline at end of file
diff --git a/app/src/main/res/menu/main_popup.xml b/app/src/main/res/menu/main_popup.xml
new file mode 100644
index 0000000..8779ef1
--- /dev/null
+++ b/app/src/main/res/menu/main_popup.xml
@@ -0,0 +1,6 @@
+
+
\ No newline at end of file
diff --git a/app/src/main/res/menu/table.xml b/app/src/main/res/menu/table.xml
new file mode 100644
index 0000000..132bcc9
--- /dev/null
+++ b/app/src/main/res/menu/table.xml
@@ -0,0 +1,18 @@
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
new file mode 100644
index 0000000..eca70cf
--- /dev/null
+++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
new file mode 100644
index 0000000..eca70cf
--- /dev/null
+++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 0000000..898f3ed
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
new file mode 100644
index 0000000..dffca36
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 0000000..64ba76f
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
new file mode 100644
index 0000000..dae5e08
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..e5ed465
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
new file mode 100644
index 0000000..14ed0af
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..b0907ca
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
new file mode 100644
index 0000000..d8ae031
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644
index 0000000..2c18de9
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
new file mode 100644
index 0000000..beed3cd
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml
new file mode 100644
index 0000000..4491c8c
--- /dev/null
+++ b/app/src/main/res/values-zh-rCN/strings.xml
@@ -0,0 +1,28 @@
+
+
+ SQLite编辑器
+
+ “SQLite编辑器”用于对SQLite数据库进行增删改查等操作。\n\n
+ 注意:本应用的图标不需要也将不会出现在启动器中。\n\n
+ Copyright © 2017–2018 Yaerin All rights reserved.\n
+
+ 注意:本应用的图标不需要也将不会出现在启动器中。
+ 我知道了
+ 确定
+ 取消
+ 撤销
+ 重做
+ 保存
+ 删除
+ 新建表
+ 执行SQL
+ 开源仓库
+ 编辑 %s [%s]
+ 你确定?
+ 此操作不可逆。
+ Success
+ 新数据
+ 在此输入SQL语句
+ 未定义唯一键
+ 不能编辑BLOB数据
+
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
new file mode 100644
index 0000000..f9596b3
--- /dev/null
+++ b/app/src/main/res/values/colors.xml
@@ -0,0 +1,6 @@
+
+
+ #ff273238
+ #ff22272b
+ #ff009387
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
new file mode 100644
index 0000000..bc435c5
--- /dev/null
+++ b/app/src/main/res/values/strings.xml
@@ -0,0 +1,28 @@
+
+
+ SQLite编辑器
+
+ "SQLite Editor" used to create/retrieve/update/delete SQLite Database\n\n
+ Notice: the application icon WILL NOT appear in the launcher.\n\n
+ Copyright © 2017–2018 Yaerin All rights reserved.\n
+
+ Notice: the application icon WILL NOT appear in the launcher.
+ I know
+ OK
+ Cancel
+ Undo
+ Redo
+ Save
+ Delete
+ Create table
+ Execute SQL
+ Open Source
+ Edit %s [%s]
+ Are you sure?
+ This action is irreversible.
+ Success
+ New value
+ Type SQL statements here
+ There is no physical unique key defined
+ Cannot edit BLOB data
+
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
new file mode 100644
index 0000000..44dc807
--- /dev/null
+++ b/app/src/main/res/values/styles.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/test/java/ma/mhy/sqliteeditorroot/ExampleUnitTest.java b/app/src/test/java/ma/mhy/sqliteeditorroot/ExampleUnitTest.java
new file mode 100644
index 0000000..11a0607
--- /dev/null
+++ b/app/src/test/java/ma/mhy/sqliteeditorroot/ExampleUnitTest.java
@@ -0,0 +1,17 @@
+package ma.mhy.sqliteeditorroot;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see Testing documentation
+ */
+public class ExampleUnitTest {
+ @Test
+ public void addition_isCorrect() {
+ assertEquals(4, 2 + 2);
+ }
+}
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..621b37d
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,29 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+buildscript {
+ repositories {
+ google()
+ jcenter()
+
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:3.3.0-alpha13'
+
+ // NOTE: Do not place your application dependencies here; they belong
+ // in the individual module build.gradle files
+ }
+}
+
+allprojects {
+ repositories {
+ google()
+ jcenter()
+ maven {
+ url "https://jitpack.io"
+ }
+ }
+}
+
+task clean(type: Delete) {
+ delete rootProject.buildDir
+}
diff --git a/gradle.properties b/gradle.properties
new file mode 100644
index 0000000..1487463
--- /dev/null
+++ b/gradle.properties
@@ -0,0 +1,14 @@
+# Project-wide Gradle settings.
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+org.gradle.jvmargs=-Xmx1536m
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
+
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..f6b961f
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..b16d083
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Sun Oct 14 15:33:24 CST 2018
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
diff --git a/gradlew b/gradlew
new file mode 100644
index 0000000..cccdd3d
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,172 @@
+#!/usr/bin/env sh
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+ echo "$*"
+}
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+ cd "$(dirname "$0")"
+fi
+
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000..f955316
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,84 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 0000000..e7b4def
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1 @@
+include ':app'
| |