Android : Delete One Specific Table Of A Database - Leave Rest Intact
Apr 23, 2010
I have a database where I store two different kinds of data. One table is for favorite routes, the other stores the retrieved routes from a server.
I can retrieve the routes etc just fine. But after retrieving the first Route, pressing back or HOME, and then retrieving another route, the routes table is filled with all the old routes plus the new ones.
So my question: how do I delete ONLY the routes table and not the whole database because I don't want to delete the added favorites?
I found the following function in the android docs:
public int delete (String table, String whereClause, String[] whereArgs) and I tried to implement it, but I must pass a SQLiteDataBase as an argument. But how?
I implemented: public void deleteTableRoutes(SQLiteDataBase db){ db.delete("routes", null, null);}
But I want to call this function from a different class where I have no reference to the database.. so what do I have to pass as an argument? Or how do I get a reference to my database?
I build my database upon the code example of the NotePadExample from the dev docs.How to solve this problem?
This is an extract of my class from where I want to call deleteTableRoutes(...)
private String start_from;
private String destination;
private int hour;
private int min;
private int day;
private int month;
private Source source;
private List<Element> tempList;
private List<Element> routes;
private String startT = "";
private String arrivalT = "";
private String duration = "";
private String line = "";
private boolean first=true;
private List<ResultElement> finalResult;
private List<Element> results;
private DbAdapter mDbHelper;
View 3 Replies
Jul 22, 2010
I have a table with column headings: | _id (long) | Name (String) | x (integer) | y (integer) |
I want to delete the row in the table that has Name myName.
// In onCreate
dbHelper = new DBAdapter(this);
dbHelper.open()
// Function in DBAdapter class
public boolean deleteTitleGivenName(String myName)
{return dbHelper.delete(DATABASE_TABLE_2, KEY_NAME + "=" + myName, null) > 0;}
// Function call in java code
dbHelper.deleteTitleGivenName(myName); // this is where my code fails
dbHelper.close();
Just as a note: myName is for sure in the database. Also, I can not use the ROWID since I am getting myName from a ListView.
I just started programming with Android and I have tried for days to solve this problem.
Is my WHERE clause correct (KEY_NAME + "=" + myName)?
View 2 Replies
View Related
Jan 31, 2010
I`am trying to delete a specific row in database.
i am deleting by using this query:
Uri myUri = Uri.parse("content://com.idan.datastorageprovider/maps");
this.getContentResolver().delete(myUri, "ROUTE_NAME="+routeName,null);
in my database i have 2 columns: ROUTE_NAME,ROUTE_PATH. and i want to delete a row by the column ROUTE_NAME, while i give it a value of which row in that column i want to delete. i get no errors, but the row is still there.
View 1 Replies
View Related
May 24, 2014
I just performed a full wipe of my HTC One M7 and flashed a new rom. Once it was done I downloaded Titanium backup from the Play Store and restored all my backed up data. Note that I didn't back up my SMS messages with Titanium, just my SMS app, Textra.
Once it was done I opened up Textra and all my messages were sitting there just as they were before the wipe.
I'm pretty sure that Google doesn't backup things like SMS messages, so where did they come from?
View 1 Replies
View Related
May 31, 2009
Before I create a table, how can I know whether the table already exist in database? How to query?
View 3 Replies
View Related
Jul 28, 2009
I'm working at an application about SQLite database. I have inserted some table in an database file. But I don't know how to get all the tables' name using code. For example, I defined a database object SQLiteDatabase dataBase = SQLiteDatabase.openOrCreateDatabase(getDatabasePath("Mydatabase"), null); and how can I get all the table names stored in the database file "Mydatabase". Counld anyone give me some code.
View 9 Replies
View Related
Apr 20, 2010
how to clear a table in android database.
View 3 Replies
View Related
May 13, 2010
I have already having 2 tables in a database now i want to create a new table in that database it self how can i create?
View 3 Replies
View Related
Jan 22, 2009
to dear all Android developers, I need to know the UTC bias of my phone to correct the UTC time information I got from a site. I have read earlier posts and already found the solution to get TimeZone information from the "System.currentTimeMillis();" method. However, I need to translate the TimeZone (as like, "Asia/Taipei") to the UTC bias that it has to be (as like, "UTC+8" or other formats). Does anyone know the actual API solution? I have surveyed android.util.TimeUtils and found nothing to do this. The worst solution may I have is to build a "TimeZone/UTC" database table to translate this..
View 3 Replies
View Related
Oct 11, 2010
I am new to andriod.I am creating a table and inserting the values into table by using sql lite.Now i need to change vales based on the id.how can i done this pls post some code.
View 2 Replies
View Related
Oct 20, 2009
I am working on a project for a belgium Tv Guide. Now I download a database (.db) file from a server to the sdcard to work with. In this database are 2 tabels, tvchannels and tvprograms. Now I can do several updates to the tvchannels table and i want to make a backup of this table to a lokal database file. How can i do that? I want to do this because I have to download a new database file every daye from the server and the channels that are choses are saved in the tvchannels database. I want to backup this database table and when the new database file (tvgids.db) is downloaded I want to replace the tvchannels database (from downloaded database file) with the backup from tvchannels..
View 6 Replies
View Related
Oct 18, 2010
I recently purchased an application and didn't like it. I've since uninstalled it.
However it shows up on my Market application ==> download section. It says "Purchased".
How do I remove this entry from that list while keeping the rest?
View 5 Replies
View Related
Sep 12, 2010
I want my app to access database every hour and read next record from the table then update desctop widget and send notification. I know that there is AlarmManager which I can use to register my Intents but they are deleted when the phone is turned off or rebooted. Is there any other android class/service that I would update my application continuously even when I reboot my phone?
View 2 Replies
View Related
Jan 21, 2010
In Android when you upgrade a database all data is lost. I'm going through a phase of development right now that is forcing many database upgrades. I don't want to lose all my data (and have to manually re-enter it) each time I upgrade my database. I would like to store my data in flat files and load those flat files into their respective tables each time a database upgrade occurs.
My questions is: What is the best way to go about this on the Android platform? Where should I store the data files (res/raw???) What sql should I execute to load these files?
View 2 Replies
View Related
Sep 30, 2010
I did a search and found nothing in the forums that was directly related to this so I started a new thread.I just got my EVO last night.I have two email accounts.A hotmail account, and an Exchange Activesync account.Both are set up and are working fine.Coming from a Blackberry, I am used to deleting the least important emails from the phone as I am on the road, leaving them to be handled later when I am at the computer.My job is email driven so I get 100+ per day from my work account.It is important to me to be able to delete the emails that can wait from the phone, leaving only the most important ones for me to answer while on the road.I called Sprint and after they played with the phone for 20 minutes while on hold, they could not find a way to delete emails from the EVO but leave them on the server for later download by computer.
View 5 Replies
View Related
Nov 3, 2010
I want to read data from database and displayed it in table layout form. table will contain n rows and 2 columns. But row size is not fixed then how to show them in table layout format?
View 5 Replies
View Related
Nov 14, 2011
i'm trying to access (read & write) from non-default (example 2nd table) table of a sqlite database which i created using sqlite database browser. but somehow, i cant seems to find the way to access it.
Code:
public class DatabaseHelper extends SQLiteOpenHelper {
private static String DB_PATH = "/data/data/com.sg/databases/";
private static String DB_NAME = "TestDatabase";
private SQLiteDatabase myDatabase;
[code]...
select data method works, but i can only select from table 1 and not table 2
View 4 Replies
View Related
Nov 24, 2010
I have created a table named train_table in SQLite database with 3 columns. they are train_id, train_no and train_name. Now, i wrote a class in which i displayed the train_name in a list view. how do i get the related train_no in the next page? can anyone help me in sorting this problem.?
View 2 Replies
View Related
May 22, 2010
In my project, I would like to create a database with single table. I would also like to insert data on this table from word or excel document. is it possible? if so please how can I do it? some code snippets would be of great help. I have four different activities which I would like them to interact with this single table. the first is the main activity and its purpose is just to launch the other three activities according to user choice. so it has no interaction with the DB. but the other three activities will read from the table whenever called. Can you please tell me how to call the dbhelper on these activities? I am unable to do this and I am currently creating one db per each activity which is not the optimal way.
View 1 Replies
View Related
Aug 18, 2010
Couldn't find an answer to this...
Say I'm typing a text message and a call comes in or I go to another app or screen for some reason,(didnt send text) then come back to the messaging app the test I was typing(but didnt finish and send) is gone and I have to retype it.
Is there a setting so it doesn't delete it?
The Pre was nice because it would keep the typed unsent test till it was deleted or sent.
View 7 Replies
View Related
Jul 2, 2010
I have a main activity that takes elements from a database and displays them in a clickable listview. I use this method to accomplish the task...
View 1 Replies
View Related
Jun 30, 2010
I am new to android application development.I have create registration form with user name,password, email. this values should be stored in sqlite database table. retrieve the data from the table. in login.java i have create the table and insert the values of registration form data in to the table dynamically. In databsehelper.java extends the databaseopenHelper class overwrite the oncreate and upgrade methods.this class i used this class in login.java. In display.java i am going to display the data in on success register details. there are no errors but it gives the error on the emulator unexpectedly stoped...................
View 1 Replies
View Related
Aug 25, 2010
I m trying to delete a record from a SQLiteDB via Android Application,This is the way that i used the code to delete the record..
View 4 Replies
View Related
Mar 2, 2010
in my app i want to delete the sms's/calls of specific numbers i am new to android can any body help me
View 1 Replies
View Related
Jul 23, 2010
I need a database in which I can store data and get data whenever I need. Is this possible with android.preference package. I do not want to use sqlite database.
View 1 Replies
View Related
Mar 23, 2010
How do I delete the sqlite database exists in my android? There is a db behind my android qro and delete the same
View 4 Replies
View Related
Aug 2, 2010
public void delete(String id, String name, String phonenumber, String time, String message)
{
String[] args={id};
getWritableDatabase().delete("texts", "_ID=?", args);
}
It works fine, and deletes the specified row. However, I also want to implement it so that I can delete the most recent (earliest date) entry in the database, which should be at the top of the table. I know I can do this by altering the last 2 parameters of delete, but I cannot figure out what to change them to.
View 1 Replies
View Related
Aug 30, 2010
android code to delete the database from the application?
View 4 Replies
View Related
Aug 7, 2009
I created a table with the name SONGS in the assets/folder. And after that I create a new project, my project run to create a database name "data" with table name "BOOKS". But I found that the table "SONGS" also created in my new database? And now my database have two table "BOOKS" and "SONGS". I don't know why? How can I delete completely the "SONGS" table?
View 2 Replies
View Related
Aug 13, 2010
Is there an equivalent view structure to the iPhone default table cell? The default table cell formats an image (icon) and text in a nice looking way. Are there suggested equivalents for Android? Is there a sample somewhere?
View 1 Replies
View Related