Android Open Source - MockSQLiteInflater Main Activity






From Project

Back to project page MockSQLiteInflater.

License

The source code is released under:

MIT License

If you think the Android project MockSQLiteInflater listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package dev.xiao.xesam.less.android.demo.db;
// ww w  .  j  a v  a2  s . c om
import android.app.Activity;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteQueryBuilder;
import android.os.Bundle;
import android.widget.TextView;
import dev.xiao.xesam.less.android.debug.db.MockSQLiteInflater;
import dev.xiao.xesam.less.android.debug.db.MockTable;

public class MainActivity extends Activity {

  public String aliasTableName = "test";
  public String dbName = "mock.db";
  
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    MockSQLiteInflater sqLiteInflater = new MockSQLiteInflater();
    SQLiteDatabase db2 = sqLiteInflater
          .addTable(MockTable.newAssetTable("mock_table.csv",aliasTableName))
          .reInflateTo(this, dbName);

    SQLiteQueryBuilder sqb = new SQLiteQueryBuilder();
    sqb.setTables(aliasTableName);
    Cursor c = sqb.query(db2, null, null, null, null, null, null);
    try {
      StringBuilder sb = new StringBuilder();
      while (c.moveToNext()) {
        sb.append(c.getString(0)).append(",").append(c.getInt(1)).append(",").append(c.getString(2)).append("\n");
      }
      ((TextView) findViewById(R.id.demo_output)).setText(sb.toString());
    } finally {
      c.close();
    }
    db2.close();

  }
}




Java Source Code List

dev.xiao.xesam.less.android.debug.db.MockSQLiteInflater.java
dev.xiao.xesam.less.android.debug.db.MockScheme.java
dev.xiao.xesam.less.android.debug.db.MockTable.java
dev.xiao.xesam.less.android.demo.db.MainActivity.java