-
Notifications
You must be signed in to change notification settings - Fork 0
Android_Example_en
رامي مناف edited this page Sep 8, 2020
·
2 revisions
This is an example for how to use Sofof as a local database in Android:
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Server server = new Server(new File(getBaseContext().getFilesDir(), "db"), -1, false);
try {
server.createDatabase();
server.startUp();
server.execute(new Bind("hello android"));
String result = server.query(new Select(String.class)).get(0).toString();
Toast.makeText(getBaseContext(), result, Toast.LENGTH_LONG).show();
}catch (Exception ex){
Log.e("", ex.toString());
}
}
}in build.gradle you have to add the following compileOptions to android section to allow use for Java 8 features.
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}