TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Lagishetty Sandeep
NA
15
11k
About Application data(local settings) & Sqlite( winphn8.1)
Sep 17 2015 12:56 PM
I have a small doubt about using SQLite database and local settings. I have an idea about how to use local settings for an app. When we
use Application data(local settings) in our application we can restore the previous state of the application. Can we use sqlite local database to
store and retrieve the values while we use local settings.(Windows phone 8.1)
Windows.Storage.ApplicationDataContainer data = Windows.Storage.ApplicationData.Current.LocalSettings;
protected async override void OnNavigatedTo(NavigationEventArgs e)
{
if (data.Values["check"] != null)
{
this.Frame.Navigate(typeof(BlankPage1));
}
if (data.Values["add"] != null)
{
list_view.Items.Add(data.Values["add"].ToString());
}
if (data.Values["remove"] != null)
{
list_view.Items.Remove(data.Values["remove"]);
}
var dbpath = ApplicationData.Current.LocalFolder.Path + "/Mydb1.db";
var con = new SQLiteAsyncConnection(dbpath);
await con.CreateTableAsync<list>();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
if(!mypop.IsOpen)
{
mypop.IsOpen = true;
}
}
public async void Button_Click_1(object sender, RoutedEventArgs e)
{
var dbpath = ApplicationData.Current.LocalFolder.Path + "/Mydb1.db";
var con = new SQLiteAsyncConnection(dbpath);
list l = new list();
data.Values["add"] = l.list1;
l.list1 = text_input.Text.ToString();
await con.InsertAsync(l);
await con.UpdateAllAsync(l.list1);
data.Values["add"] = l.list1;
list_view.Items.Add(data.Values["add"].ToString());
// list_view.Items.Add(text_input.Text.ToString());
mypop.IsOpen = false;
}
private void Button_Click_2(object sender, RoutedEventArgs e)
{
if(mypop.IsOpen)
{
mypop.IsOpen = false;
}
}
private async void Button_Click_3(object sender, RoutedEventArgs e)
{
var dbpath = ApplicationData.Current.LocalFolder.Path + "/Mydb1.db";
var con = new SQLiteAsyncConnection(dbpath);
list l = new list();
data.Values["remove"] = l.list1;
l.list1 = list_view.SelectedItem.ToString();
list_view.Items.Remove(list_view.SelectedItem);
List<list> mylist = await con.QueryAsync<list>("delete from list where list1='" + list_view.SelectedItem + "'");
mylist.Remove(l);
Please check and verify the code. I can only store single value to local settings. When I restart my application only one value will be shown. It
wont show the values inserted in the listview. Please also check delete query. It is not working.. please help me...
Reply
Answers (
0
)
Article c-sharpcorner/UploadFile/raj1979/broa
Searching a database and displaying results in a textbox c#