ذخیره داده های دریافت شده از سرور در دیتابیس Sqlite و عدم بازخوانی داده های تکراری از سرور
فک کنم عنوان سوالم واضح باشه ! خب یکسری اطلاعات که عکس هم شامل میشه رو میخوام وقتی به صورت Json از سرور دریافت کرد و توی لیست ویو نشون داد اونارو هم توی دیتابیس Sqlite روی گوشی ذخیره کنه . بار یعدی که کاربر اومد تو برنامه دیگه نره از سرور چیزی بگیره همونایی که توی Sqlite هستند رو نمایش یده . مگر اینکه کاربر دکمه ابدیت رو بزنه یا لیست رو Pull to Refresh کنه . مرسی از دوستان . لطفا HELP ! :)))
public static void readOfTableDB() {
Cursor cursor = database.rawQuery("SELECT DISTINCT mds_name,mds_some, mds_vahed,mds_pricevahed, mds_pricecomplete,mds_date, mds_month,mds_year FROM MDS", null);
while (cursor.moveToNext()) {
String name = cursor.getString(cursor.getColumnIndex("mds_name"));
int some = cursor.getInt(cursor.getColumnIndex("mds_some"));
String vahed = cursor.getString(cursor.getColumnIndex("mds_vahed"));
double priceVahed = cursor.getDouble(cursor.getColumnIndex("mds_priceVahed"));
double priceComplete = cursor.getDouble(cursor.getColumnIndex("mds_priceComplete"));
int date = cursor.getInt(cursor.getColumnIndex("mds_date"));
int month = cursor.getInt(cursor.getColumnIndex("mds_month"));
int year = cursor.getInt(cursor.getColumnIndex("mds_year"));
adapter = new ActivityAdapterNote(G.notes);
StructNote note = new StructNote();
note.txtName = name;
note.txtSome = some;
note.txtVahed = vahed;
note.txtPriceVahed = priceVahed;
note.txtPriceComplete = priceComplete;
note.txtDate = date;
note.txtMonth = month;
note.txtYear = year;
note.done = true;
G.notes.add(note);
adapter.notifyDataSetChanged();
}
cursor.close();
}
public static void insertToDB(String name, int some, String vahed, double priceVahed, double priceVaheComplete, int data, int month, int year) {
if (name != null) {
database.execSQL("INSERT INTO MDS " +
"(mds_name," +
"mds_some," +
"mds_vahed," +
"mds_priceVahed," +
"mds_priceComplete," +
"mds_date," +
"mds_month," +
"mds_year) " +
"VALUES ('" + name + "'," +
"" + "'" + some + "'," +
"" + "'" + vahed + "'," +
"" + "'" + priceVahed + "'," +
"" + "'" + priceVaheComplete + "'," +
"" + "'" + data + "'," +
"" + "'" + month + "'," +
"" + "'" + year + "'" + ")");
}
}
این سوال رو دوباره تو انجمن بع عنوان سوال ارسال کن بخش Note یعنی بخش 11 و 12 رو خوب یاد بگیرید اگه یک هفته هم طول بکشه یادش بگیر تا زمانی که یادش نگرفتی نرو روی چیز دیگه ای
پاسخگویی و مشاهده پاسخ های این سوال تنها برای اعضای ویژه سایت امکان پذیر است .
چنانچه تمایل دارید به همه بخش ها دسترسی داشته باشید میتوانید از این بخش لایسنس این آموزش را خریداری نمایید .