android-sqlite-generator
android-sqlite-generator copied to clipboard
small fix!
congrats!
I know after all this work, this is nothing!!
no primary key defined - generation correct
primary key defined - generation dodgy
hmm, what about create the table class (setters&getters) ?
then at ProviderClient we can have something like :
//Automotodetails the table class (setters&getters)
public static List<Automotodetails> getAllAutomotodetailss(Context c) {
List<Automotodetails> automotodetailss = new ArrayList<Automotodetails>();
Automotodetails automotodetails = null;
Cursor cursor = getAllTable(c);
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
automotodetails = cursorToAutomotodetails(cursor);
automotodetailss.add(automotodetails);
cursor.moveToNext();
}
// Make sure to close the cursor
cursor.close();
return automotodetailss;
}
private static Automotodetails cursorToAutomotodetails(Cursor cursor) {
if (cursor == null || cursor.getColumnCount() == 0)
return null;
Automotodetails automotodetails = new Automotodetails();
automotodetails.setautomotodetail_id(cursor.getLong(0));
automotodetails.setautomoto_id(cursor.getLong(1));
automotodetails.setkm_daterec(cursor.getString(2));
automotodetails.setkm_counter(cursor.getLong(3));
automotodetails.setfixes(cursor.getString(4));
automotodetails.setcost(cursor.getDouble(5));
automotodetails.setwhere(cursor.getString(6));
automotodetails.setcomment(cursor.getString(7));
automotodetails.setautomotodetail_daterec(cursor.getString(8));
automotodetails.setautomotodetail_guid(cursor.getString(9));
return automotodetails;
}
on activity/fragment will work like :
List<Automotodetails> automotodetailss = AutomotodetailsContentProviderClient.getAllAutomotodetailss(this);
Toast.makeText(this, String.valueOf(automotodetailss.size()), 3000).show();
on create database better do in transaction (?)
@Override
public void onCreate(SQLiteDatabase db) {
Log.d(TAG, "Creating a new Database. Current version " + DATABASE_VERSION);
db.beginTransaction();
try {
db.execSQL(DATABASE_AUTOMOTODETAILS_CREATE);
db.execSQL(DATABASE_AUTOMOTOS_CREATE);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}
forgot to add is primary key
tuning_id INTEGER --> PRIMARY KEY
on sqlitehelper create table variables
here need to be "item" ?
where at delete/update procedures working like charm by UNIQUEID var!
still confused again with "_id" what happening here ? how can be row query there ? I have to modify each with table_PK ?
thanks!!!
updated http://www.pipiscrew.com/works/sqlite-manager-v1-0/
v1.8.3 - generate table structure for Trikke – android-sqlite-generator!