I did an android application, its about the pharmacy on duty. I want to change it in every month but when I download it my device from google store, it shows the old month information. So what can I do for delete old month information and show new month information? Here is my code for this app.
import android.app.Activity;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.widget.TextView;
import static com.ahmety.eczanezonguldak.Sbtalapli.*;
public class Alapli extends Activity {
private Vtalapli data;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.alapli);
data = new Vtalapli(this);
try{addData("","","","");
addData("17.06.2015","Pharmacy Name ","pharmacy addres","pharmacy tel no");
Cursor cursor = getData();
showData(cursor);
}
finally{
data.close();
}
}
private void addData(String date, String pharmacy, String address, String tel){
SQLiteDatabase db = data.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(DATE, date);
values.put(PH,pharmacy);
values.put(ADDRESS,address);
values.put(TEL,tel);
db.insertOrThrow(TABLE_ALAPLI, null, values);
}
private static String[] SELECT = {DATE, PH, ADDRESS,TEL};
private Cursor getData(){
SQLiteDatabase db = data.getReadableDatabase();
Cursor cursor = db.query(TABLE_ALAPLI, SELECT, null, null, null, null, null);
startManagingCursor(cursor);
return cursor;
}
private void showData(Cursor cursor){
StringBuilder builder = new StringBuilder(" Nöbetçi Eczane/Alapli\n\n\n "
+ " Tarih Eczane Addres Tel\n");
while(cursor.moveToNext()){
String date = cursor.getString((cursor.getColumnIndex(DATE)));
String ph = cursor.getString((cursor.getColumnIndex(PH)));
String address = cursor.getString((cursor.getColumnIndex(ADDRESS)));
String tel = cursor.getString((cursor.getColumnIndex(TEL)));
builder.append(date).append(" ");
builder.append(ph).append(" ");
builder.append(address).append(" ");
builder.append(tel).append("\n");
}
TextView text = (TextView)findViewById(R.id.textalapli);
text.setText(builder);
}
}
Aucun commentaire:
Enregistrer un commentaire