android


there is any way to save my shared preferences data into sqlite database in android


problem : i wanted to save my shared preferences data into sqLite database permanently.i here provides my code which store my data into shared preferences folder but when i am trying to store new data the previous one destroy .............is there is any solution to save the data permanently into table .........thanks in advance
public class CustomerWorkOrder extends Activity implements OnClickListener {
EditText etname ,etphone,etvname,etvno,etsdate,etldate,etremarks,etamount;
Button save,Load;
SharedPreferences SomeData;
TextView tv;
public static String filename="MySharedString";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_customer_work_order);
save=(Button) findViewById(R.id.button1);
Load=(Button) findViewById(R.id.button2);
etname=(EditText) findViewById(R.id.editText1name);
etphone=(EditText) findViewById(R.id.editText2pnum);
etvno=(EditText) findViewById(R.id.editText3vvno);
etvname=(EditText) findViewById(R.id.editText4vvname);
etsdate=(EditText) findViewById(R.id.editText6sdate);
etldate=(EditText) findViewById(R.id.editText5ldts);
etamount=(EditText) findViewById(R.id.editText7amnt);
etremarks=(EditText) findViewById(R.id.editText8remk);
save.setOnClickListener(this);
Load.setOnClickListener(this);
SomeData=getSharedPreferences(filename, 0);
}
#Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
switch(arg0.getId()){
case R.id.button1:
String stringData=etname.getText().toString();
String stringData1=etphone.getText().toString();
String stringData2=etvno.getText().toString();
String stringData3=etvname.getText().toString();
String stringData4=etsdate.getText().toString();
String stringData5=etldate.getText().toString();
String stringData6=etamount.getText().toString();
String stringData7=etremarks.getText().toString();
SharedPreferences.Editor editor=SomeData.edit();
editor.putString("SharedString", stringData);
editor.putString("SharedString1", stringData1);
editor.putString("SharedString2", stringData2);
editor.putString("SharedString3", stringData3);
editor.putString("SharedString4", stringData4);
editor.putString("SharedString5", stringData5);
editor.putString("SharedString6", stringData6);
editor.putString("SharedString7", stringData7);
editor.commit();
etname.setText("");
etphone.setText("");
etvno.setText("");
etvname.setText("");
etsdate.setText("");
etldate.setText("");
etamount.setText("");
etremarks.setText("");
break;
case R.id.button2:
SomeData=getSharedPreferences(filename, 0);
String dataReturned=SomeData.getString("SharedString", "could not load the data");
String dataReturned1=SomeData.getString("SharedString1", "could not load the data");
String dataReturned2=SomeData.getString("SharedString2", "could not load the data");
String dataReturned3=SomeData.getString("SharedString3", "could not load the data");
String dataReturned4=SomeData.getString("SharedString4", "could not load the data");
String dataReturned5=SomeData.getString("SharedString5", "could not load the data");
String dataReturned6=SomeData.getString("SharedString6", "could not load the data");
String dataReturned7=SomeData.getString("SharedString7", "could not load the data");
etname.setText(dataReturned);
etphone.setText(dataReturned1);
etvno.setText(dataReturned2);
etvname.setText(dataReturned3);
etsdate.setText(dataReturned4);
etldate.setText(dataReturned5);
etamount.setText(dataReturned6);
etremarks.setText(dataReturned7);
break;
}
}}
Perhaps this excellent tutorial will get you started quick with SQLite.

Related Links

WebView not working consistently
RelativeLayout - android:layout_centerHorizontal=“true” AND android:gravity=“center_horizontal” showing unexpected results
How can I debug C++ source code of a native library using Android Studio 2.3?
How can TextView be aligned right next to a Buttin in LinearLayout
Android Studio StackOverFlowError: null
searchView in toolbar has a paddingBottom when fitsSystemWindows
should I use a database or string.xml for port mapping data
Testing Internet Connection With Firebase [closed]
Camera and media player desync
Kotlin synthetic extension and several include same layout
How to measure size (KB) of an interstitial received from publicity SDK
Can't see navigation drawer and toolbar when i change fragment
Firebase API initialization failure,java.lang.reflect.InvocationTargetException
Geolocation in the building outside the city
How to Stream Android Screen live through Media Recorder
Google map v2 Heatmap for specific location

Categories

HOME
httparty
gridview
checkstyle
dns
ns-3
pyqt
fftw
jelastic
xbee
cublas
onclick
vert.x
barcode
okhttp
octave
github-enterprise
ycsb
plink
cumulocity
feathersjs
asp.net-mvc-viewmodel
soci
blade
systemtime
inno-download-plugin
exit
highstock
xcode-ui-testing
siri
stackexchange
pylons
nsurl
panoramas
zend-debugger
catch-unit-test
wacom
papaparse
card.io
fiware-cygnus
flatmap
sim-card
health-monitoring
ogc
skylink
linqpad
placeholder
file-sharing
apache-spark-dataset
httrack
wcftestclient
configurationmanager
twilio-click-to-call
tf
payara-micro
pair-programming
scalding
appdomain
context-sensitive-grammar
subnet
arules
otp
rackspace-cloud
node-request
xcode-server
macaulay2
drawstring
i386
scaffolding
vorpal.js
pre-build-event
createprocess
relativelayout
fiware-monitoring
doctype
sony-lifelog-api
ocra
pyobjc
snoop
mraid
diff3
cryptographichashfunction
rapidsvn
packet-sniffers
paw
xml-namespaces
create.js
angular-carousel
named-parameters
build-script
personalization
dot42
spring-remoting
android-framework
ie8-compatibility-mode
model-driven-development
nebula
jquery-1.9
chart-director
xcode3.2
boost-signals
subproject
stress
exponentiation
ruby-1.8
vs-android
isapi-extension
request-headers
murmurhash
strtod
glui
interop-domino
escrow
fault-tolerance
pbcopy
great-circle

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App