Если вы хотите войти без каких-либо остальных API. тогда вы должны попробовать локальную базу данных, как sqlite.
public class DataBaseHelper extends SQLiteOpenHelper {
private String TAG = "DataBaseHelper";
private SQLiteDatabase mSqLiteDatabase;
private Context mContext;
/*Constructor call when you initialize DataBasseHelper class*/
public DataBaseHelper(Context context) {
super(context, DataBaseConstants.DATABASE_NAME, null, DataBaseConstants.DATABASE_VERSION);
this.mContext = context;
}
/*onCreate Method is used to create table */
@Override
public void onCreate(SQLiteDatabase db) {
Logger.e(TAG, "call onCreate");
db.execSQL("create table userInfo (id integer primary key AUTOINCREMENT, email text NOT NULL,password text NOT NULL, createdDate text NOT NULL)");
}
/*onUpgrade Method call when database version changed,
that time exsting table delete and new table create.
when we want new table create that time onCreate method will use.*/
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Logger.e(TAG, "call onUpgrade");
if (oldVersion < newVersion) {
db.execSQL("DROP TABLE " + "tableName");
onCreate(db);
}
}
/*onCopydatabase Method is used to copy existing database*/
public boolean onCopyDatabase(Context context) {
Logger.e(TAG, "call onCopyDatabase");
try {
InputStream inputStream = context.getAssets().open(DataBaseConstants.DATABASE_NAME);
String dbPath = mContext.getDatabasePath(DataBaseConstants.DATABASE_NAME).getPath();
String outFileName = dbPath + "/" + DataBaseConstants.DATABASE_NAME;
Logger.e(TAG, "Database path is : " + outFileName);
OutputStream outputStream = new FileOutputStream(outFileName);
byte[] buff = new byte[1024];
int length = 0;
while ((length = inputStream.read(buff)) > 0) {
outputStream.write(buff, 0, length);
}
outputStream.flush();
outputStream.close();
Log.w(TAG, "DataBase copied");
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
}