This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.msd.jetty; | |
public class App { | |
public static void main(String[] args) { | |
final Jetty jetty = new Jetty(8080); | |
jetty.start(); | |
Thread.sleep(500); | |
if (false == jetty.isStarted()) { | |
throw new Exception("Cannot start jetty server"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.msd.jetty; | |
import com.google.gson.Gson; | |
import com.google.gson.JsonObject; | |
import java.io.IOException; | |
import javax.servlet.ServletException; | |
import javax.servlet.http.HttpServlet; | |
import javax.servlet.http.HttpServletRequest; | |
import javax.servlet.http.HttpServletResponse; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.msd.jetty; | |
import java.io.IOException; | |
import javax.servlet.ServletException; | |
import javax.servlet.http.HttpServlet; | |
import javax.servlet.http.HttpServletRequest; | |
import javax.servlet.http.HttpServletResponse; | |
@SuppressWarnings("serial") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.msd.jetty; | |
import com.google.gson.Gson; | |
import com.google.gson.GsonBuilder; | |
import org.eclipse.jetty.server.Server; | |
import org.eclipse.jetty.servlet.ServletContextHandler; | |
import org.eclipse.jetty.servlet.ServletHolder; | |
public class Jetty extends Server { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.test.db; | |
import android.content.ContentValues; | |
import android.content.Context; | |
import android.database.Cursor; | |
import android.database.sqlite.SQLiteDatabase; | |
import android.database.sqlite.SQLiteOpenHelper; | |
import android.util.Log; | |
import java.util.List; | |
import com.test.db.MainActivity.Data; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.test.db; | |
import android.app.Activity; | |
import android.os.Bundle; | |
import android.util.Log; | |
import java.util.LinkedList; | |
import java.util.List; | |
public class MainActivity extends Activity { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyDb extends SQLiteOpenHelper { | |
public static final String TAG = "MyDb"; | |
public static final int VERSION = 1; | |
public static final String DATABASENAME = "mydb"; | |
public MyDb(Context context) { | |
super(context, DATABASENAME, null, VERSION); | |
} | |
@Override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Cursor cursor = getReadableDatabase(). | |
rawQuery("select * from data where ID = ?", new String[] { _id }); | |
database.query("data", | |
new String[] { ID, DATA_ID, VALUE }, | |
null, null, null, null, null); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public synchronized String getDataValue(long _id) { | |
final SQLiteDatabase db = this.getReadableDatabase(); | |
String retval = null; | |
try { | |
Cursor cursor = db.query("data", new String[]{"VALUE"}, | |
"ID = ?", new String[]{String.valueOf(_id)}, null, null, null); | |
if (cursor != null) { | |
if (cursor.moveToFirst()) { | |
do { | |
retval = cursor.getString(0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public synchronized boolean addData(List<YourObject> _objects) { | |
final SQLiteDatabase db = this.getWritableDatabase(); | |
boolean retval = false; | |
try { | |
for (YourObject object : _objects) { | |
ContentValues contentValues = new ContentValues(); | |
contentValues.put("ID", object.id); | |
contentValues.put("DATA_ID", object.dataId); | |
contentValues.put("VALUE", object.value); | |
db.insert("data",null,contentValues); |
NewerOlder