Skip to content

Instantly share code, notes, and snippets.

@xcesco
xcesco / AlbumDao.java
Created September 28, 2018 23:10
Parameter in content provider URL can be ${placeHolder} or :{placeHolder} or :placeHolder
@BindContentProviderPath(path = "albums")
@BindDao(Album.class)
public interface AlbumDao extends BaseDao<Album> {
@BindContentProviderEntry(path = ":{id}")
@BindSqlSelect(where = "id=:{id}")
List<Album> select(long id);
}
@xcesco
xcesco / DaoPerson.java
Created September 28, 2018 23:02
parameter in query string can be ${placeHolder} or :{placeHolder} or :placeHolder
@BindDao(Person.class)
public interface DaoPerson {
@BindSqlSelect(where="name=${name}")
List<Person> select1(String name);
@BindSqlSelect(where="name=:{name}")
List<Person> select2(String name);
@BindSqlSelect(where="name=:name")
List<Person> select3(String name);
/**
* In the user device was already installed the app with version 1 of the datasource so an upgrade is needed.
*
* @throws Exception
*/
@Test
public void testUpgrade() throws Exception {
// Context of the app under test.
Context testContext = InstrumentationRegistry.getContext();
Context context = InstrumentationRegistry.getTargetContext();
/**
* In a user device is installed the app with the version 2 of the SQLite data source.
*
* @throws Exception
*/
@Test
public void testInstallVersion2() throws Exception {
// Context of the app under test.
Context testContext = InstrumentationRegistry.getContext();
Context context = InstrumentationRegistry.getTargetContext();
@BindType
@BindSqlType
public class Country {
@BindSqlColumn(columnType = ColumnType.PRIMARY_KEY)
public long id;
public long area;
@BindSqlColumn(nullable = false, columnType = ColumnType.UNIQUE)
public String code;
@xcesco
xcesco / version-1
Created May 16, 2018 22:09
xeno.schema
CREATE TABLE country (id INTEGER PRIMARY KEY AUTOINCREMENT, area INTEGER, code TEXT UNIQUE NOT NULL, calling_code TEXT NOT NULL, region TEXT, name TEXT NOT NULL, translated_name BLOB);
CREATE TABLE prefix_config (id INTEGER PRIMARY KEY AUTOINCREMENT, default_country TEXT, dual_billing_prefix TEXT, enabled INTEGER, dialog_timeout INTEGER);
CREATE TABLE phone_number (id INTEGER PRIMARY KEY AUTOINCREMENT, action TEXT, number TEXT, country_code TEXT, contact_name TEXT, contact_id TEXT);
@BindSqliteType(name = "cheeses")
public class Cheese {
public long id;
public String name;
}
public class MainActivity extends AppCompatActivity {
private static final int LOADER_CHEESES = 1;
private CheeseAdapter mCheeseAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
05-15 00:01:56.956 createHelper (line 437): Database file /data/user/0/com.abubusoft.kripton.examples.rssreader/databases/rss.db
05-15 00:01:56.984 onCreate (line 253): Create database 'rss.db' version 1
05-15 00:01:56.984 onCreate (line 259): DDL: CREATE TABLE rss_feed (id INTEGER PRIMARY KEY AUTOINCREMENT, uid TEXT UNIQUE, version TEXT);
05-15 00:01:56.986 onCreate (line 265): DDL: CREATE TABLE channels (id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT, link TEXT UNIQUE, description TEXT, language TEXT, copyright TEXT, pub_date TEXT, last_build_date TEXT, image BLOB, rss_feed_id INTEGER, FOREIGN KEY(rss_feed_id) REFERENCES rss_feed(id));
05-15 00:01:56.987 onCreate (line 271): DDL: CREATE TABLE articles (id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT, description TEXT, link TEXT, author TEXT, guid TEXT UNIQUE NOT NULL, comments TEXT, channel_id INTEGER, thumbnail BLOB, read INTEGER, FOREIGN KEY(channel_id) REFERENCES channels(id));
05-15 00:01:56.992 I/AbstractDataSource, openWritableDatabase (line 618):
public class MainActivity extends AppCompatActivity {
private RecyclerView recyclerView;
private ArticlesAdapter adapter;
RssViewModel viewModel;
private String[] filterValues;
@Override